Lean 4 Project Template

License: Apache 2.0

This repository contains a template for blueprint-driven formalization projects in Lean 4.

Install Lean 4

Ensure that you have a functioning Lean 4 installation. If you do not, please follow the Lean installation guide.

Use this Template

To create a new repository using this template, follow these steps:

  1. Click the Use this template button located at the top right of the repository page.
  2. Click the Create a new repository button.
  3. Select the account or organization where you want to create it, choose a name for the new repository, and click the Create repository button.

Configure GitHub Pages

To set up GitHub Pages for your repository, follow these steps:

  1. Go to the Settings tab of your repository.
  2. Scroll down to the Pages section.
  3. In the Source dropdown, select GitHub Actions.
  4. Click Save.

Repository Layout

The template repository is organized as follows (listing the main folders and files):

  • .github contains GitHub-specific configuration files and workflows.
    • workflows contains GitHub Actions workflow files.
      • lint.yml is the style lint workflow triggered on push and pull request events.
    • dependabot.yml is the configuration file to automate CI dependency updates.
  • .vscode contains Visual Studio Code configuration files
  • Project should contain the Lean code files.
    • Mathlib should contain .lean files with declarations missing from existing Mathlib developments.
    • ForMathlib should contain .lean files with new declarations to be upstreamed to Mathlib.
    • Example.lean is a sample Lean file.
  • scripts contains scripts to update Mathlib ensuring that the latest version is fetched and integrated into the development environment.
  • .gitignore specifies files and folders to be ignored by Git. and environment.
  • CONTRIBUTING.md should provide the guidelines for contributing to the project.
  • lakefile.lean is the configuration file for the Lake build system used in Lean projects.
  • lean-toolchain specifies the Lean version and toolchain used for the project.

Customize this Template

To tailor this template to your specific project, you need to:

  • lint.yml: Find and replace Project with your actual project name.
  • Project: Rename the folder to match your actual project name.
  • Project/Example.lean: Remove it and replace it with your actual project code.
  • CONTRIBUTING.md: Customize the guidelines for contributing to the project.
  • lakefile.lean: Find and replace Project with your actual project name.
  • Project.lean: Rename the main file and the imports to match your actual project name.

Blueprint

0. Selected Real-World Collaborative Projects

For more examples of completed and ongoing Lean projects and libraries, please see the Lean Reservoir.

1. Install Dependencies

Verify your Python installation by running:

python3 --version

and your Pip installation by running:

pip3 --version

If you don't have a Python environment, you can install one by following the instructions in the Python installation guide.

To install the necessary dependencies, follow the instructions in the PyGraphViz installation guide.

2. Install LeanBlueprint Package

Assuming you have a properly configured Python environment, install LeanBlueprint by running:

pip install leanblueprint

If you have an existing installation of LeanBlueprint, you can upgrade to the latest version by running:

pip install -U leanblueprint

3. Configure Blueprint

To set up the blueprint for your project, run:

leanblueprint new

Then, follow the prompts and answer the questions as you like, except for a few specific questions which should be answered as indicated below to ensure compatibility with this template.

Respond affirmatively with y to the following prompt:

Proceed with blueprint creation? [y/n]

Respond affirmatively with y to the following prompt:

Modify lakefile and lake-manifest to allow checking declarations exist? [y/n] (y)

Respond affirmatively with y to the following prompt:

Modify lakefile and lake-manifest to allow building the documentation? [y/n] (y):

If you want to generate a Jekyll-based home page for the project, respond affirmatively with y to the following prompt:

Do you want to create a home page for the project, with links to the blueprint, the API documentation and the repository? [y/n]:

Respond affirmatively with y to the following prompt:

Configure continuous integration to compile blueprint? [y/n] (y):

For more details about the LeanBlueprint package and its commands, please refer to its documentation.