|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a **Linear Algebra Game** built using the [lean4game](https://github.com/leanprover-community/lean4game) framework. It's an educational game that teaches linear algebra concepts through interactive theorem proving in Lean 4, based on Sheldon Axler's "Linear Algebra Done Right" textbook. |
| 8 | + |
| 9 | +## Build System and Development Commands |
| 10 | + |
| 11 | +The project uses Lake (Lean 4's build system): |
| 12 | + |
| 13 | +- `lake build` - Build the entire project |
| 14 | +- `lake clean` - Remove build outputs |
| 15 | +- `lake update` - Update dependencies and save to manifest |
| 16 | +- `lake exe <exe>` - Build and run an executable |
| 17 | +- `lake env <cmd>` - Execute command in Lake's environment |
| 18 | + |
| 19 | +## Project Structure |
| 20 | + |
| 21 | +### Core Game Files |
| 22 | +- `Game.lean` - Main game configuration with title, introduction, and world dependencies |
| 23 | +- `Game/Data.lean` - Extensive mathlib imports for mathematical definitions |
| 24 | +- `Game/Metadata/Metadata.lean` - Game metadata and server commands |
| 25 | +- `Game/MyTactic.lean` - Custom tactic imports for the game |
| 26 | + |
| 27 | +### Game Worlds (Educational Levels) |
| 28 | +The game is organized into sequential worlds: |
| 29 | + |
| 30 | +1. **TutorialWorld** (`Game/Levels/TutorialWorld/`) - Introduction to Lean 4 basics |
| 31 | +2. **VectorSpaceWorld** (`Game/Levels/VectorSpaceWorld/`) - Vector space concepts |
| 32 | +3. **LinearIndependenceSpanWorld** (`Game/Levels/LinearIndependenceSpanWorld/`) - Linear independence and span |
| 33 | + |
| 34 | +Each world: |
| 35 | +- Has a main `.lean` file (e.g., `TutorialWorld.lean`) that imports all levels |
| 36 | +- Contains individual level files (`Level01.lean`, `Level02.lean`, etc.) |
| 37 | +- Uses the `World`, `Level`, `Title`, `Introduction`, `Statement`, `Conclusion` commands |
| 38 | + |
| 39 | +### Level Management |
| 40 | +- `sofi.sh` - Script for reordering and renaming level files within worlds |
| 41 | +- Levels must follow `L**.lean` or `L**_*****.lean` naming convention |
| 42 | +- The script automatically updates level numbers and imports |
| 43 | + |
| 44 | +## Key Dependencies |
| 45 | + |
| 46 | +- **Lean 4.7.0** - The proof assistant |
| 47 | +- **mathlib 4.7.0** - Comprehensive mathematics library |
| 48 | +- **lean4game** - Game framework (local or remote depending on `LEAN4GAME` env var) |
| 49 | +- **checkdecls** - Declaration checking tool (currently experiencing compatibility issues) |
| 50 | + |
| 51 | +## Development Workflow |
| 52 | + |
| 53 | +1. **Adding New Levels**: Create level files following naming convention, then run `./sofi.sh <world_path>` to reorder |
| 54 | +2. **Level Structure**: Each level includes `World`, `Level`, `Title`, `Introduction`, `Statement`, `Conclusion` |
| 55 | +3. **Tactic Documentation**: Use `TacticDoc` and `NewTactic` commands to document tactics |
| 56 | +4. **World Dependencies**: Configure in `Game.lean` (e.g., VectorSpaceWorld → LinearIndependenceSpanWorld) |
| 57 | + |
| 58 | +## Mathematical Content |
| 59 | + |
| 60 | +The game covers: |
| 61 | +- Vector spaces and their properties |
| 62 | +- Linear independence and span |
| 63 | +- Bases and linear transformations |
| 64 | +- Proof techniques using Lean 4 tactics (`rfl`, `apply`, `intro`, etc.) |
| 65 | + |
| 66 | +## Local Development |
| 67 | + |
| 68 | +For local development with the game framework: |
| 69 | +- Set `LEAN4GAME.local=true` in Lake configuration |
| 70 | +- Ensure the lean4game server is available at `../lean4game/server` |
| 71 | +- Use `lake build` to compile the game |
| 72 | +- The game generates a web interface for interactive theorem proving |
| 73 | + |
| 74 | +## Architecture Notes |
| 75 | + |
| 76 | +- **Game Framework Integration**: Uses lean4game's `GameServer.Commands` for web interface |
| 77 | +- **Tactic System**: Imports extensive mathlib tactics while filtering some for educational purposes |
| 78 | +- **World Organization**: Sequential progression with dependency management |
| 79 | +- **Educational Design**: Focuses on proof techniques rather than computation |
| 80 | + |
| 81 | +## Known Issues |
| 82 | + |
| 83 | +### Blueprint CI Failure (Commit 26b662f) |
| 84 | +The blueprint setup commit fails in CI due to checkdecls compatibility issues: |
| 85 | +- **Issue**: checkdecls package has syntax errors with current Lean 4.7.0 |
| 86 | +- **Temporary Fix**: Checkdecls step is commented out in `.github/workflows/blueprint.yml` |
| 87 | +- **Resolution**: Need to update checkdecls to a compatible version or fix the syntax issue |
| 88 | +- **Files affected**: `lakefile.lean`, `blueprint/lean_decls`, `.github/workflows/blueprint.yml` |
| 89 | + |
| 90 | +### Checkdecls Usage |
| 91 | +- `blueprint/lean_decls` should list Lean declarations referenced in blueprint |
| 92 | +- Currently empty as blueprint content is minimal |
| 93 | +- Use `--` for comments in `lean_decls` file, not `#` |
0 commit comments