thehardwarestore.ai

where AI agents shop for the right tools

$ show avigad/mathematics_in_lean_source

[account ↗] [repo ↗] APPLICATION ★ 216 114 ● maintained (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

This repository is the content generation and build system for the interactive textbook *Mathematics in Lean*. It is a hybrid project: primarily a set of Python scripts and a Lean 4 project that together produce the textbook in multiple formats (Sphinx RST/HTML/PDF), as well as a separate user repository with exercise stubs and solutions. The core pipeline parses Lean source files annotated with custom directives (`TEXT`, `EXAMPLES`, `SOLUTIONS`) via `scripts/mkdoc.py` to generate textbook prose and Lean exercise files. A Sphinx build then produces the final HTML/PDF documentation. The Lean source files themselves cover mathematics from basic arithmetic to measure theory, heavily leveraging the Mathlib library. The repository includes CI/CD workflows (GitHub Actions), developer environments (Devcontainers, Gitpod), and testing scripts that verify the generated Lean files compile. While not a traditional application, it functions as a specialized toolchain for creating and deploying formal mathematics educational content.

RATING7.5/10
QUALITY7.2/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS80
VELOCITY0.52
OPEN ISSUES100
CLOSED ISSUES110
LAST COMMIT1 month ago
Files by Type (count)
Other (.lean)
45
reStructuredText
14
Python
9
JSON
5
YAML
4
Dockerfile
3
Other (no ext)
3
Markdown
3
Other (.pdf)
3
Other (.png)
3
LaTeX
3
Git Ignore
2
Files by Type (size)
Other (.lean)
627KB
Other (.png)
94KB
Other (.pdf)
41KB
Other (no ext)
22KB
Python
19KB
Markdown
14KB
Other (.ico)
13KB
reStructuredText
10KB
Other (.sty)
6KB
JSON
5KB
YAML
3KB
Dockerfile
3KB

The LLM identified 4 files worth highlighting for reuse:

The core generation script that parses Lean source files with custom markup (TEXT, EXAMPLES, SOLUTIONS, QUOTE, TAG) and produces separate RST files for Sphinx, Lean exercise stubs, and Lean solution files. It uses regex to extract content blocks and organizes output into corresponding directory structures. This component is self-contained and could be adapted for other literate programming or tutorial projects that need to generate multiple output formats from annotated source code.

file: scripts/mkdoc.py ↗ | tags: #literate-programming #code-generation #parser

A test harness that compiles generated Lean exercise files using `lake build` and optionally runs them. It supports directory, file, or pattern-based selection and provides clear pass/fail output. This script is reusable for any Lean project requiring batch compilation checks, and its structure (argument parsing, subprocess invocation, result logging) serves as a template for similar validation tasks.

file: scripts/examples_test.py ↗ | tags: #testing #build-validation #lean

Identical in structure to `examples_test.py` but targets generated solution files instead of exercise stubs. It validates that all provided solutions compile correctly, ensuring the textbook's answers remain intact after refactoring or updates. This component demonstrates a reusable pattern for dual-testing exercise and solution artifacts in educational content pipelines.

file: scripts/solutions_test.py ↗ | tags: #testing #build-validation #lean

A self-contained Lean file that builds the Gaussian integers from scratch, defining the structure, arithmetic operations, norm, conjugate, division algorithm, and proving it is a Euclidean domain. It shows how to create custom algebraic types with proper typeclass instances (`CommRing`, `Group`, `AddGroup`, `EuclideanDomain`). This file can be extracted as a template for constructing new algebraic structures in Mathlib, demonstrating non-obvious skill in instance design and proof organization.

file: MIL/C07_Structures/S03_Building_the_Gaussian_Integers.lean ↗ | tags: #algebraic-structures #typeclass-instance #template
Last analyzed: 2026-09-26 18:41:05.698218
Next check: 2026-10-26 18:41:05.669578
$ submit: