# Chess proof: what can be proved, bounded and measured about chess

The request was to solve chess: find a forced win from the starting position that holds against every defence.
**That has not been found here, and no such line is known to exist.** Strong engines and expert analysis point to the
starting position being a draw with best play, and everything measured in this directory agrees. Settling it exactly
would mean searching a game with roughly 4.8 × 10⁴⁴ legal positions.

What this directory does instead, in D0RE's discipline (exact claims, independent verification, no trust in a learned
score): it proves what can be proved, bounds what can be bounded, and labels everything else as engine evidence.

## Where things stand (23 November 2026)

| result | status | write-up |
|---|---|---|
| 60 held-out forced mates in 3, each with a strategy tree checked by a second, independent rules engine | **proved** | [01](docs/01-mate-prover.md) |
| From the starting position White cannot force mate within 13 plies (11 plies re-derived by the D0RE engine alone) | **proved**, a bound | [01](docs/01-mate-prover.md) |
| A move-ranking network of eight named integer weights, trained in Tally, that only reorders moves and can never make a proof wrong | measured | [01](docs/01-mate-prover.md) |
| Forcing-move logic (checks, captures, promotions, mate threats, forks, squeezes), with its deep-threat mode, finds all 360 known mates; it needs 8× fewer search calls on forced mates in 5 | measured | [02](docs/02-forcing-logic.md) |
| A player limited to its top 5 logical moves plays every game at 90%+ accuracy and still loses to unrestricted Stockfish | measured | [02](docs/02-forcing-logic.md) |
| What Stockfish reacts to, what a piece is worth where it stands, the shortest forced material gain, the formula wheel | measured | [03](docs/03-stockfish-probes.md) |
| Chess on 8 files and 4 ranks: White mates in one | **proved** | [04](docs/04-minichess.md) |
| The atlas: size, the opening tree to four plies, the value of a tempo, blind systems | derived and measured | [05](docs/05-atlas.md) |
| Stockfish's perfect game (a depth-24 Berlin draw) holds against deviations three levels deep | engine evidence | [06](docs/06-perfect-game.md) |
| A "unicorn" on 8 × 8 (a move that wins although the loser never left best play): **none found**; every candidate fell to a deeper defender | engine evidence | [07](docs/07-unicorn.md) |
| Chess on 8 files and 6 ranks: a winning strategy for White (1.a4) that passes every engine check | engine evidence, **not a proof** | [07](docs/07-unicorn.md) |

Chess itself is **not solved**: the value of the starting position stays in [−1, +1]. Scores from Stockfish and
Fairy-Stockfish are evidence, never proof; only the rows marked proved rest on exhaustive search and an independent check.
[`SOLVING_CHESS.md`](SOLVING_CHESS.md) sets out what a real solution would take.

## Layout

```
README.md            this overview
SOLVING_CHESS.md     how chess could be solved: obstacles, what cancels each, a staged plan
docs/                the write-ups, one per topic (01 to 07)
*.py                 49 scripts, kept flat so that they import each other by name
data/                every result file the scripts write and read (JSON, logs, saved search trees)
figures/             the six figures
proofs/              60 verified strategy trees (mates in 3)
proofs_deep/         40 verified strategy trees (mates in 4 and 5)
```

Run every script from this directory. A script writes its results to `data/` and its figures to `figures/`; file names
below and in the write-ups are given without that prefix.

## What is here

### Forced-mate prover and move ranker ([write-up](docs/01-mate-prover.md))

| file | role |
|---|---|
| `mate_prover.py` | the prover: AND/OR search, iterative deepening, strategy trees, a failure cache; the eight named move features |
| `verify_proof.py` | checks a strategy tree with the D0RE engine: legal White moves, real checkmates, exactly the full set of Black replies, and no draw Black can claim |
| `d0re_engine.py` | the D0RE C3 engine, copied unchanged from `dist/archive/15a71bf67222-full_chess_state_engine.py` |
| `build_corpus.py` | random sparse positions, solved exactly: 300 forced mates in 2 (every White move labelled winning or not) for training, 60 forced mates in 3 held out for testing → `corpus.json` |
| `export_tally_data.py` | writes the training set as a Tally library, `research/tally/lib/chess_mate_data.tly` |
| `../tally/chess/chess_ranking_network.tly` | the network, trained in Tally |
| `benchmark.py` | retrains the network in Python, requires identical weights to Tally's, then proves the 60 held-out mates under three move orders and verifies every proof → `benchmark_results.json`, `proofs/` |
| `initial_position.py` | the starting-position bound with python-chess → `initial_position.json` |
| `initial_position_d0re.py` | the same bound re-derived with the D0RE engine alone, one worker per White first move → `initial_position_d0re.json` |

### Forcing-move logic and logical moves in play ([write-up](docs/02-forcing-logic.md))

| file | role |
|---|---|
| `../tally/chess/chess_forcing_logic.tly` | the rule that combines the six forcing classes, tested in Tally on every labelled training move. The classes themselves are computed in Python (`mate_prover.py`) and exported as 0/1 facts (`lib/chess_logic_data.tly`) |
| `logic_benchmark.py` | full-width against forcing search on the 360 known mates → `logic_benchmark_results.json` |
| `deep_benchmark.py` | 40 forcing mates in 4 and 5 from random positions, verified, and full-width search on the same positions → `deep_benchmark_results.json`, `proofs_deep/` |
| `play_games.py` | 48 Stockfish self-play games, every legal move of every position scored at depth 12 → `play_corpus.json` |
| `play_logic.py` | sixteen named facts about a move in ordinary play |
| `play_benchmark.py` | the Tally perceptron on those facts (`../tally/chess/chess_play_network.tly`), and how few moves keep 90%+ → `play_benchmark_results.json` |
| `reduce_logic.py` | tunes integer weights on Stockfish's verdict and cancels every fact it cannot tell apart; Tally re-derives the counts (`../tally/chess/chess_play_logic.tly`) → `reduce_logic_results.json` |
| `logic_games.py` | real games by a player restricted to its top k logical moves, with an unrestricted control → `logic_games_results.json` |

### Probing Stockfish ([write-up](docs/03-stockfish-probes.md))

| file | role |
|---|---|
| `stockfish_probe.py`, `probe_analysis.py` | Stockfish's reply to every legal move against its reply to a pass, and what predicts a reaction → `stockfish_probe.json`, `probe_analysis.json` |
| `piece_value.py`, `piece_patterns.py` | occlusion probe of each piece's value where it stands, named photon facts, patterns and heat maps → `piece_value.json`, `piece_patterns.json`, `piece_heatmaps.png` |
| `advantage_prover.py`, `advantage_benchmark.py` | the shortest forced material gain against every defence, the least-counterplay line (chosen in `../tally/chess/chess_forced_advantage.tly`), and the starting-position bound → `advantage_results.json` |
| `chess_wheel.py` | the chess formula wheel (`chess_wheel.svg`, `chess_wheel.png`): Material, Time, Space and Safety in place of V, I, R and P, every entry read from a result file and tagged proved, measured, defined or cited; its claims checked in `../tally/chess/chess_wheel.tly` |

### Minichess ([write-up](docs/04-minichess.md))

| file | role |
|---|---|
| `minichess.py`, `minichess_ref.py`, `solve_minichess.py` | chess on 8 files and H = 4..8 ranks: an engine (identical to python-chess at 8 ranks), an independent rules check written another way, and the forced-mate search → `solve_minichess_<H>.json` |
| `fairy.py`, `rows_pattern.py` | Fairy-Stockfish on the same boards (perft agrees for 5–7 ranks): evaluations and self-play → `rows_pattern.json` |

### Atlas and blind systems ([write-up](docs/05-atlas.md))

| file | role |
|---|---|
| `atlas_perft.py`, `atlas_openings.py`, `atlas_report.py`, `atlas_ply4.py`, `atlas_report4.py`, `atlas_unique.py` | the bird's-eye atlas: perft with components to depth 5, geometry, the value of a tempo, the opening tree to three plies scored by Stockfish 16, named openings, flaws and the f/g-pawn pattern → `atlas.json`, `chess_atlas.png` |
| `blind_system.py` | how long a fixed White system can be played without looking at Black, the most blind-safe sequence, and six human systems against 40 varied opponents → `blind_system.json` |

### The perfect game and its deviations ([write-up](docs/06-perfect-game.md))

| file | role |
|---|---|
| `perfect_game.py` | Stockfish's best guess at the perfect game (depth 24 self-play) and every alternative at every move tested at depth 20 → `perfect_game.json` |
| `ribs.py`, `ribs_recheck.py` | one level deeper: 60 deviations from the perfect game played out and attacked, flagged breaks re-checked at depth 22 → `ribs.json`, `ribs_recheck.json` |
| `ribs3.py`, `ribs3_check.py` | level three: the most tempting deviation inside each drawn rib, played out at depth 20, attacked, breaks re-checked at depth 24 and played on, decisive ribs checked at depth 30 → `ribs3.json`, `ribs3_check.json` |
| `anatomy.py` | anatomy of the perfect game: the cost of every deviation, how many moves hold, two saddle matrices, the ribs' basin, self-play at other depths → `anatomy.json`, `perfect_game_anatomy.png` |

### The unicorn hunt ([write-up](docs/07-unicorn.md))

| file | role |
|---|---|
| `unicorn.py` | the unicorn hunt: every move in 1 283 positions near the perfect game screened at depths 8 and 16 for hidden moves that rise with depth; all 188 checked at depth 28, survivors at depth 32 and played out → `unicorn.json` |
| `unicorn_chase.py`, `unicorn_certify.py`, `unicorn_duel.py` | chasing the near-unicorns: depth-24 play-outs with a check of the losing side's earlier moves, certification by best defence with exact tablebase endings, and a duel in which the defender searches 4× longer → `unicorn_chase.json`, `unicorn_duel_8_32.json` |
| `unicorn_others.py` | the unicorn hunt on Stockfish's other perfect games (depths 16–22, played to the end) → `others_games.json`, `unicorn_others.json`, `unicorn_others_duels.json` |
| `unicorn_pn.py` | the unicorn search from the first move: engine-guided proof-number search for a forced win, for either side → `unicorn_pn_white.json`, `unicorn_pn_black.json` |
| `unicorn_mini.py` | the same search on 8 files and 5 or 6 ranks (Fairy-Stockfish), resumable from its saved tree → `unicorn_mini_5.json`, `unicorn_mini_6.json` (tree: `unicorn_mini_6.pkl`), `unicorn_mini_6_1500.json`, `unicorn_mini_6_4500.json` |
| `unicorn_mini_certify.py` | certifies a proved minichess tree: cut replies re-checked at depth 20, leaves and best cut replies played out at equal depth; its holes and failures go back into the search → `unicorn_mini_6_w200_certify*.json` (+2 branch: `unicorn_mini_6_w200.json`, `.pkl`) |

### Plan and self-check

| file | role |
|---|---|
| `SOLVING_CHESS.md` | how chess could be solved: the size equation, nine obstacles with what cancels each and the measured number behind it, and a staged programme |
| `test_chess_proof.py` | fast self-check (a few seconds) |

## Prior D0RE work

From the D0RE chess reading path (*Dimensional Chess*, records C1–C8 and run R1, mirrored in
`dist/library/paths/chess.html`). Checked against the live site on 18 November 2026: www.d0re.com's chess path and all
12 records it links are identical to the mirror, and C8 is the latest chess record. The register revision of 23
November 2026 adds this study to that path as its latest step (`/research/notes/chess-proof.html`); C8 stays the latest
record of the Dimensional Chess series.

| record | result |
|---|---|
| C1–C2 | exact KRK and KQK solutions with a proved symmetry quotient; a frozen full-chess target |
| C3–C4 | a full-rules engine (castling, en passant, promotion, repetition and move-count draws) passing perft; constraint waves on KRK and KQK |
| C5–C6, R1 | tension maps and exchange-dependency move ordering; at the initial position neither side forces mate within 7 plies, and R1 concludes that "ordering is not the wallbreaker" |
| C7–C8 | horizon-safe state projection; learned movement-frequency ordering of defender moves; neither side forces mate within 9 plies |

C8 left the value of the initial position in [−1, +1] and named the open problem: *a learned relation that carries
a sound interval or proof obligation.* This directory makes the learned part carry a proof obligation. Nothing the
network suggests is accepted until it becomes a strategy tree that a second engine checks. It does not narrow the
root interval.

## What this does and does not show

- **Proved:** 60 random positions, each with a forced mate in 3 and a strategy tree checked by an independent engine.
  The search is exhaustive, so these are proofs, not engine opinions. Any strong engine finds such short mates; the
  point is the checkable certificate and the measured effect of the learned ordering.
- **Bounded:** White cannot force mate from the starting position within 13 plies, and within 11 plies on two
  independent engines. That is a true statement about chess with a known ceiling. It says nothing about the result
  with best play.
- **Not solved:** chess. The value of the starting position stays in [−1, +1], as C8 left it. Nothing here narrows it.
- **Minichess, 8 files × 6 ranks:** an engine-certified winning strategy for White (1.a4, 134 Black nodes, every reply
  covered, all 330 end positions won at equal depth). Strong evidence, not a proof. It says nothing about 8 × 8.
- **Logic, not trust:** the forcing rule only removes White moves, so it can make the search miss a mate but can
  never make it accept a false one. Its six named classes are computed in `mate_prover.py`; the rule that combines them is written and measured in Tally.
- **The black box:** the network is eight named integer weights trained by a visible rule, and it is never trusted.
  It reorders moves; the prover still examines all of them, and every result is a certificate checked by separate
  code. That is a stronger guarantee than readable weights alone.
- **Limits of the benchmark:** sparse random endgames with one to three White and up to three Black pieces besides
  the kings, trained on mates in 2 and tested on mates in 3. Deeper mates and full middlegame positions are untested. The
  hand-written rule is one fixed baseline, not a tuned one. The no-claims relaxation is used only for the
  starting-position bound; the benchmark proofs obey the full rules, and the verifier checks that.

## Reproduce

```
pip install --use-pep517 chess      # python-chess 1.11.2
python test_chess_proof.py          # a few seconds; needs Stockfish 16 (below)
python build_corpus.py              # about 20 minutes, seed 7 → data/corpus.json
python export_tally_data.py         # → ../tally/lib/chess_mate_data.tly
(cd ../tally && python tally.py chess/chess_ranking_network.tly)   # about 100 s
python benchmark.py                 # a few minutes plus the Tally run
python initial_position.py 7        # about 13 minutes (11 plies: 90 s)
python initial_position_d0re.py 6 3 # about 10 minutes on 3 cores
(cd ../tally && python tally.py chess/chess_forcing_logic.tly)     # about 1 minute
python logic_benchmark.py           # about 30 s
python deep_benchmark.py            # about 15 minutes on 4 cores, seed 11
apt-get install stockfish           # Stockfish 16 at /usr/games/stockfish
python play_games.py 48 4           # 4 cores; the slowest step with logic_games.py
python play_benchmark.py            # includes the Tally training run
python reduce_logic.py              # includes the Tally check
python logic_games.py 8 4 0 1 3 6 10 99 && python logic_games.py 12 4 8 3 4 5 6
```

The later studies (probes, atlas, perfect game, ribs, unicorn hunt, minichess searches) are long engine runs. Each
write-up in `docs/` names its script and settings, and each script's docstring gives its command line.
