A minimal Lean 4 development environment using VSCode DevContainer. This setup provides a consistent development environment with Lean 4, making it easy to start theorem proving and functional programming.
- 🐳 Docker-based: Consistent development environment using DevContainer
- 🎯 Minimal Size: Optimized Dockerfile based on debian:bookworm-slim
- 🔧 Pre-configured: VSCode extensions and settings ready to use
- 🚀 Quick Setup: One-click development environment activation
- Clone this repository
git clone https://github.com/chantakan/lean4-devcontainer-template.git
cd lean4-devcontainer-template- Open in VSCode
code .- Reopen in Container
When VSCode opens, you'll see a notification asking to "Reopen in Container". Click it, or:
- Press
F1orCtrl+Shift+P(Windows/Linux) /Cmd+Shift+P(Mac) - Type "Dev Containers: Reopen in Container"
- Press Enter
The first build may take a few minutes. Subsequent opens will be much faster.
- Verify Installation
Once the container is built and running, open the integrated terminal in VSCode and run:
lean --version
lake --version- Run the Example
lake build
lake exe lean4-projectYou should see the output: Hello, Lean 4!
.
├── .devcontainer/
│ ├── devcontainer.json # DevContainer configuration
│ └── Dockerfile # Docker image definition
├── .gitignore # Git ignore rules
├── lakefile.lean # Lake build configuration
├── lean-toolchain # Lean version specification
├── Main.lean # Main entry point with examples
└── README.md # This file
The Main.lean file includes:
- A simple "Hello, Lean 4!" program
- Proof of commutativity of addition (two approaches)
- Examples using the
omegatactic
lake buildlake exe lean4-projectlake updateEdit the lean-toolchain file to specify a different version:
leanprover/lean4:v4.x.x
Or use:
leanprover/lean4:stable
leanprover/lean4:nightly
Edit lakefile.lean to add external Lean libraries. For example:
require mathlib from git
"https://github.com/leanprover-community/mathlib4.git"Then run lake update in the container.
- Ensure Docker is running
- Check your internet connection
- Try rebuilding:
Dev Containers: Rebuild Container
- Make sure you opened the folder in the container (check bottom-left corner of VSCode)
- Reload VSCode window:
Developer: Reload Window
If you encounter memory issues during builds:
- Increase Docker's memory allocation in Docker Desktop settings
- Recommended: at least 4GB RAM
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Lean Prover Community for the excellent documentation and tools
- All contributors to the Lean 4 project