https://github.com/dwrensha/chess.lean
Chess in Lean 4
https://github.com/dwrensha/chess.lean
lean4
Last synced: 8 months ago
JSON representation
Chess in Lean 4
- Host: GitHub
- URL: https://github.com/dwrensha/chess.lean
- Owner: dwrensha
- License: apache-2.0
- Created: 2024-09-28T12:28:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-30T18:32:46.000Z (9 months ago)
- Last Synced: 2025-09-30T20:24:51.597Z (9 months ago)
- Topics: lean4
- Language: Lean
- Homepage:
- Size: 31.3 KB
- Stars: 21
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chess in Lean 4
This is an (incomplete) implementation of chess in the Lean 4 theorem prover.
It was originally developed as part of https://github.com/dwrensha/animate-lean-proofs.
## Usage
See [Examples.lean](./Chess/Examples.lean)
```lean
theorem morphy_mates_in_two :
ForcedWin .white
╔════════════════╗
║░░▓▓░░▓▓♚]♝]░░♜]║
║♟]░░▓▓♞]▓▓♟]♟]♟]║
║░░▓▓░░▓▓♛]▓▓░░▓▓║
║▓▓░░▓▓░░♟]░░♗]░░║
║░░▓▓░░▓▓♙]▓▓░░▓▓║
║▓▓♕]▓▓░░▓▓░░▓▓░░║
║♙]♙]♙]▓▓░░♙]♙]♙]║
║▓▓░░♔}♖]▓▓░░▓▓░░║
╚════════════════╝ := by
move "Qb8"
opponent_move
move "Rd8"
checkmate
```
## Dependencies
If you plan to use the `get_next_move` tactic then you need:
* a working python setup, including `python3-venv`
* a stockfish executable
### Linux
```bash
sudo apt-get install stockfish python3-venv
```
### Mac
```bash
brew install stockfish
```
### Windows
Download a suitable binary here: https://stockfishchess.org/download/, identify the stockfish binary and set the following environment variable:
```
STOCKFISH_BIN=[path to stockfish binary]
```