A card game that changes on the integers
Result page Proof blueprint → Paper PDF Verification archive
Two players take turns writing an unused number at the end of a row, until enough of its numbers, read left to right, go up or go down. In two versions of this game the first player can force a win with fractions, and the second player with integers.
In misère play with rising length 5 and falling length 4, the first player can force a win when the cards are the fractions, while the second player can force a win when the cards are the integers and when they are the whole numbers 0, 1, 2, …; in normal play with rising length 6 and falling length 5, the first player can force a win on the fractions and the second player on the integers.
Albert, Aldred, Atkinson, Handley, Holton, McCaughan and Sagan (2009) solved normal play on the fractions for falling lengths up to 5, and wrote that, if their conjectures held, they would be surprised if similar results did not also hold for the whole numbers or the integers. Lean checked two games where the integers go the other way. The reason is that between two integers there may be no unused card left, while between two fractions there always is.
Two games the first player wins on the fractions ℚ and the second player wins on the integers ℤ
Walkthrough: 1 of 5 main results in Lean; 2 more have one half each in the Lean traced here and 2 are not proved in it
Lean re-proves the Erdős–Szekeres bound and Albert et al.’s two reductions between games, and proves its own form of their finite-order cap lemma, for misère play and with a sharper cap, for blocks of cards that run on forever at one or both ends.
Published inputs
- Erdős & Szekeres (1935) (Re-proved in Lean): Every sequence of (a − 1)(d − 1) + 1 distinct numbers has a rising run of length a or a falling run of length d.
- Albert et al. (2009) (Re-proved in Lean): On a deck with no smallest or largest card, normal play (a, d) has the same winner as misère play (a − 1, d − 1), for a, d ≥ 2 (Lemma S, their Proposition 7 and remark).
- Albert et al. (2009) (Re-proved in Lean): On ℕ, opening with the smallest card turns a win for the second player in misère (a, d) into a win for the first player in misère (a + 1, d), for a ≥ 1 and d ≥ 2 (their Section 4.1).
- Albert et al. (2009) (Re-proved in Lean): On finite orders, a gap of unused cards larger than a cap set by its label plays like any larger gap (their Proposition 6). The Lean traced here proves a form of it for misère play.
What this paper adds
- Theorem 1 in Lean: Lemma S, re-proved; Fractions, where only labels matter; Blocks of integers, counted up to a cap; The second player on ℤ and on ℕ
- Theorems 2 and 3, one half each in the Lean traced here: Normal (6, 5) on ℤ and ℕ (Theorem 2); Misère (6, 4) on ℕ and ℤ (Theorem 3)
- Propositions 4 and 5, not proved in the Lean traced here: Normal (7, 5) on ℕ and ℤ (Proposition 4); A wider table and finite decks (Proposition 5)
Misère (5, 4) and normal (6, 5): first player on ℚ, second player on ℤ
In misère play (completing a run loses) with rising length 5 and falling length 4, the first player can force a win on the fractions ℚ and the second player on the integers ℤ and on the whole numbers ℕ; in normal play (completing a run wins) with lengths 6 and 5, the first player wins on ℚ and the second player on ℤ.
1 of 5 main results proved unconditionally in the Lean traced here (Theorem 1); Theorems 2 and 3 each have one half in it (normal (6, 5) on ℤ, misère (6, 4) on ℕ); Propositions 4 and 5 are not proved in it.
Listed as open in the paper
- Conjecture 6: whether misère (a, 4) on ℤ is a second-player win exactly when a ≡ 1 or 2 (mod 4), for every a ≥ 4; and, separately, whether misère (a, 4) on ℕ is one exactly when a ≡ 1 (mod 4).
- Why the second player’s winning replies on ℤ switch from near cards (a = 5, 9) to far cards (a = 6).
- Whether misère (a, 5) on ℤ or ℕ has second-player wins for a ≥ 7.
Adjacent prior work (not used as inputs)
- Albert et al. (2009) [Misère (5, 4) and normal (6, 5) go the other way on ℤ, in Lean]: Wrote that, if their conjectures held, they would be surprised if similar results did not also hold for ℕ or ℤ; the paper refutes this expectation, which it notes is conditional rather than a formal conjecture.
- Albert et al. (2009): Computed finite decks {1, …, n} up to n = 20, determined the normal-play outcomes on ℚ for falling length d ≤ 5 (their Theorem 9), and conjectured that for a ≥ d ≥ 3 the first player wins normal and misère play on all sufficiently large finite decks, and normal play on ℚ.
- Harary, Sagan & West (1983) (not fully read): Introduced the game on small finite decks; the paper has not read this work in full.
- Pudwell (2026); Ulfarsson (2026): Pudwell solved misère play on ℚ for a ≥ d and d ≤ 5 in pattern form; Ulfarsson studied a related permutation-avoidance game.
- Nowakowski (2025): Restates Albert et al.’s conjectures for finite decks and ℚ only.
Misère play with runs of 3, by hand
Take rising length 3, falling length 3 and misère play, so the player who completes a run loses. A rising run of 3 is three cards of the row, in the order written, each larger than the one before; they need not sit next to each other. A falling run is the same with each card smaller.
On the integers the first player writes 0, the second player writes 1, and the first player writes −1. The row is now 0, 1, −1.
Any unused integer above 1 completes the rising run 0, 1, x. Any unused integer below −1 completes the falling run 1, −1, x. No integer lies strictly between −1 and 0 or between 0 and 1. So every card the second player can write completes a run, and the second player loses.
On the fractions the second player could write 1/2 instead. The row 0, 1, −1, 1/2 has rising runs 0, 1 and 0, 1/2 and −1, 1/2, and falling runs 1, −1 and 0, −1 and 1, 1/2, all of length 2 and none of length 3. So 1/2 is safe, and the game goes on.
Lean checks that the first player can force a win in this game on the integers, whatever the second player writes.
The game and who can force a win
A row ends the game once it has a rising run of length a or a falling run of length d. In misère play the player to move can force a win if some unused card ends nothing and leaves the opponent in a forced loss; in normal play a card that ends the game wins at once. For a, d ≥ 1, every position with no repeated card is a forced win or a forced loss for the player to move: always in misère play, and in normal play when the deck has infinitely many cards. It is never both.
Every misère position is a forced win or a forced loss
For a ≥ 1 and d ≥ 1, every row with no repeated card is a forced win or a forced loss in misère play for the player to move.
theorem RunGameZ.misere_determinacy {α : Type u_1} [LinearOrder α] {a : ℕ} {d : ℕ} (ha : 1 ≤ a) (hd : 1 ≤ d) {r : List α} (hnodup : r.Nodup) : MisereWin a d r ∨ MisereLoss a d r- A rising run of length a
- A falling run of length d
- A row that ends the game
- A forced win in misère play
- A forced loss in misère play
- A forced win in normal play
- A forced loss in normal play
- Every row has a rising run of length 0
- Every row has a falling run of length 0
- The empty row has no rising run of positive length
- The empty row has no falling run of positive length
- The empty row does not end the game
- A long rising run contains shorter ones
- A long falling run contains shorter ones
- A rising run survives adding cards
- A falling run survives adding cards
Labels, and why the game is short
Give each unused card v a label (f, g): f is the length of the longest rising run in the row made of cards below v, and g the length of the longest falling run made of cards above v. Writing v ends the game exactly when f + 1 reaches a or g + 1 reaches d. Label each card of a row at the moment it was written: no two cards get the same label, and while no run is complete only (a − 1)(d − 1) labels are possible. So a row of more than (a − 1)(d − 1) different cards has a rising run of length a or a falling run of length d, and the game lasts at most (a − 1)(d − 1) + 1 moves.
A row of more than (a − 1)(d − 1) different cards has a run
For a ≥ 1 and d ≥ 1, a row of more than (a − 1)(d − 1) different cards has a rising run of length a or a falling run of length d.
theorem RunGameZ.erdos_szekeres_run {α : Type u_1} [LinearOrder α] {a : ℕ} {d : ℕ} (ha : 1 ≤ a) (hd : 1 ≤ d) {r : List α} (hnodup : r.Nodup) (hlen : (a - 1) * (d - 1) < r.length) : IsTerminal a d r- The largest number in a list
- The rising part of a card's label
- The falling part of a card's label
When writing v ends the game
If the row r does not end the game, writing v ends it exactly when a ≤ f + 1 or d ≤ g + 1, where (f, g) is v's label.
theorem RunGameZ.isTerminal_append_singleton_iff {α : Type u_1} [LinearOrder α] {a : ℕ} {d : ℕ} {r : List α} (hnt : ¬IsTerminal a d r) (v : α) : IsTerminal a d (r ++ [v]) ↔ a ≤ incEnd r v + 1 ∨ d ≤ decEnd r v + 1
A game small enough to play by hand
In misère play with runs of 3 on the integers, the first player writes 0 and answers each second card by a fixed rule. After three cards no unused integer is safe, so the second player must complete a run. On the fractions the same row 0, 1, −1 still leaves 1/2 as a safe card.
The first player wins misère play with runs of 3 on the integers
In misère play with lengths 3 and 3 on the integers, the first player can force a win: write 0; answer 1 with −1, answer −1 with 1, answer a card of 2 or more with 1, and answer a card of −2 or less with −1.
theorem RunGameZ.misere_3_3_Z_first_wins : MisereWin 3 3 []
After 0, 1, −1 every integer completes a run of 3
For every integer x other than 0, 1 and −1, the row 0, 1, −1, x has a run of length 3.
theorem RunGameZ.misere_3_3_Z_0_1_neg1_all_term (x : ℤ) (hx : x ∉ [0, 1, -1]) : IsTerminal 3 3 ([0, 1, -1] ++ [x])
After 0, 1, −1 the fraction 1/2 is safe
The row 0, 1, −1, 1/2 of fractions has no run of length 3.
Two shortcuts between games
On a deck with no smallest and no largest card, such as the integers or the fractions, normal play with lengths a and d has the same winner as misère play with lengths a − 1 and d − 1, for a, d ≥ 2. On the whole numbers 0, 1, 2, …, if the second player can force a win in misère play with lengths a and d, where a ≥ 1 and d ≥ 2, then the first player can force a win with rising length a + 1 by writing 0 to begin. These are the normal-to-misère shortcut and the 0-in-front shortcut. The result page numbers the whole numbers from 1; only the order of the cards matters, so it is the same game.
On a deck without ends, normal play is misère play with runs one shorter
On a deck with no smallest and no largest card, for a, d ≥ 2 and any row with no repeated card and no rising run of length a − 1 or falling run of length d − 1, the player to move can force a win in normal play with lengths a and d exactly when they can in misère play with lengths a − 1 and d − 1, and the same for a forced loss.
For a, d ≥ 2, from the empty row on a deck without ends, normal play is misère play with runs one shorter
On a deck with no smallest and no largest card, for a, d ≥ 2, the first player can force a win in normal play with lengths a and d exactly when they can in misère play with lengths a − 1 and d − 1, and the same for a forced loss.
For d ≥ 2 on the whole numbers, if the second player wins misère play at rising length a ≥ 1, the first player wins at a + 1
On the whole numbers, for a ≥ 1 and d ≥ 2, if the second player can force a win in misère play with lengths a and d, then the first player can force a win with lengths a + 1 and d, by writing 0 to begin.
The fractions, where only labels matter
On the fractions, every unused card has a smaller and a larger unused card with the same label. So a position is fully described by the list of labels still in use, and a strategy table on such lists decides the game. A table of 20 lists, checked by Lean, shows that the first player can force a win in misère play with lengths 5 and 4, and the normal-to-misère shortcut turns this into normal play with lengths 6 and 5.
The first player wins misère play with lengths 5 and 4 on the fractions
In misère play with lengths 5 and 4 on the fractions, the first player can force a win.
theorem RunGameZ.misere_5_4_Q_first_wins : MisereWin 5 4 []
The first player wins normal play with lengths 6 and 5 on the fractions
In normal play with lengths 6 and 5 on the fractions, the first player can force a win.
- A block of cards with one label
- A list of labels
- The order of labels
- Adding a label to a list
- Adding a label if it is safe
- The labels after one move on the fractions
On the fractions every block has cards on both sides of each card
On a deck where another card lies between any two and there is no smallest or largest card, every card in a block has a smaller card and a larger card in the same block.
- A list of labels describing a row
Writing a card follows the move step
On a deck where another card lies between any two and there is no smallest or largest card: if L describes the row r and v is a safe card with label (f, g), then the move step applied to L describes r followed by v.
- A strategy table on lists of labels
- Checking the moves out of a losing list of labels
- Checking a strategy table on labels
A checked table on labels decides the game
On a deck where another card lies between any two and there is no smallest or largest card, for a, d ≥ 1: if a table passes the check, every row with no repeated card that does not end the game and is described by a losing entry is a forced loss in misère play, and one described by a winning entry is a forced win.
- The strategy table for misère play with lengths 5 and 4 on the fractions
The fractions table passes the check
Lean evaluates the check on the 20-entry table and gets true.
Blocks of integers, counted up to a cap
On the integers or the whole numbers, the unused cards with one label form a block, which is finite or endless below, above or both ways. A finite block larger than its cap, a number set by the label, plays exactly like a block of the cap's size. So a position is fully described by its blocks with sizes cut at their caps, and Lean proves that every real move gives a listed next description and every listed one comes from a real move.
A checked table on blocks decides the game
On a deck where only finitely many cards lie between any two, for a, d ≥ 1: if a table passes the check, every row with no repeated card that does not end the game and is described by a losing entry is a forced loss in misère play, and one described by a winning entry is a forced win.
- The cap of a label
The cap of a label adds up from its two neighbours
For a safe label, cap(f, g) = cap(f + 1, g) + cap(f, g + 1) + 1, the caps of the two blocks a written card splits it into, plus the card itself.
- The size of a block
- A recorded block
- A list of blocks
- A size cut at a cap
- Joining two block sizes
- Joining two possibly empty block sizes
- The size stored for a label
- Blocks in label order
- Putting a block in its place
- Adding a block
- The ways a written card can split its block
- The blocks after one move
- All block lists one move away
- A real block and its recorded size
Every real card gives a listed split
On a deck where only finitely many cards lie between any two: if a block's size is right for the cap cL + cR + 1, then any card v in it leaves a part below and a part above whose sizes, cut at cL and cR, are one of the listed splits.
Every listed split comes from a real card
On a deck where only finitely many cards lie between any two: if a block's size is right for the cap cL + cR + 1, then every listed split is made by some card of the block.
- A list of blocks describing a row
- The cards that move into a label
Writing a card follows the block move step
If pos describes the row r and v is a card of the block fg whose parts below and above have the recorded sizes bl and ab, then the move step describes r followed by v.
Every real move is a listed move
On a deck where only finitely many cards lie between any two: if pos describes a row that does not end the game, then every unused card that ends nothing leads to a row described by one of the block lists one move away.
Every listed move is a real move
On a deck where only finitely many cards lie between any two: if pos describes a row that does not end the game, then every listed move from pos is made by some unused card that ends nothing.
- A binary tree
- Looking up an entry in the tree
- Checking every entry of the tree
- A strategy table on lists of blocks
- Checking the moves out of a losing list of blocks
- Checking a strategy table on blocks
The integers and the whole numbers
A strategy table of 198 block descriptions for the integers and one of 378 for the whole numbers, both checked by Lean, show that the second player can force a win in misère play with lengths 5 and 4. The shortcuts turn these into a win for the second player in normal play with lengths 6 and 5 on the integers, and a win for the first player in misère play with lengths 6 and 4 on the whole numbers. Together with the fractions, this answers the expectation of Albert and coauthors with no, in both kinds of play.
Two games the first player wins on the fractions and the second player on the integers
In misère play with lengths 5 and 4, the first player can force a win on the fractions, and the second player can force a win on the integers and on the whole numbers. In normal play with lengths 6 and 5, the first player can force a win on the fractions, and the second player on the integers.
theorem RunGameZ.albert_et_al_2009_refuted_full : (MisereWin 5 4 [] ∧ MisereLoss 5 4 [] ∧ MisereLoss 5 4 []) ∧ NormalWin 6 5 [] ∧ NormalLoss 6 5 []
A weaker form: two games the first player wins on the fractions but not on the integers
In misère play with lengths 5 and 4, and in normal play with lengths 6 and 5, the first player can force a win on the fractions and cannot on the integers.
On the whole numbers, rising length 5 and 6 differ
On the whole numbers, in misère play with falling length 4, the second player can force a win with rising length 5, and the first player with rising length 6.
The second player wins normal play with lengths 6 and 5 on the integers
In normal play with lengths 6 and 5 on the integers, the first player is in a forced loss.
theorem RunGameZ.normal_6_5_Z_second_wins : NormalLoss 6 5 []
The first player wins misère play with lengths 6 and 4 on the whole numbers
In misère play with lengths 6 and 4 on the whole numbers, the first player can force a win.
theorem RunGameZ.misere_6_4_N_first_wins : MisereWin 6 4 []
- The strategy table for the integers
The integers table passes the check
Lean evaluates the check on the 198-entry table and gets true.
The second player wins misère play with lengths 5 and 4 on the integers
In misère play with lengths 5 and 4 on the integers, the first player is in a forced loss.
- The strategy table for the whole numbers
The whole numbers table passes the check
Lean evaluates the check on the 378-entry table and gets true.
The second player wins misère play with lengths 5 and 4 on the whole numbers
In misère play with lengths 5 and 4 on the whole numbers, the first player is in a forced loss.