math-ai-org/mathcode

MathCode: A Frontier Mathematical Coding Agent

MathCode – A Coding Assistant for Formal Mathematics

What it is

  • MathCode is a terminal‑ and browser‑based coding assistant that integrates tightly with the Lean 4 proof assistant. It lets you write code and formal proofs, query the current proof goal, search Lean libraries, and verify that a proof is correct.

Key capabilities

  • Lean‑4 powered proof checking – MathCode can inspect goals, search declarations, test candidate lemmas and run Lean’s strict verifier to confirm a proof.
  • Dual UI – Use a command‑line interface (mathcode …) or launch a local WebUI that renders mathematics and diagrams.
  • Knowledge vault – Verified theorems and their explicit assumptions can be stored and explored in an Obsidian vault, giving a personal library of results and dependency graphs.
  • Extensible skills – You can add Python analysis tools, custom “MCP” plugins, and other project‑specific skills to the agent.

How to get started

  1. Clone the repo and run the provided setup.sh script.
  2. Authenticate the required codex backend (codex auth login).
  3. Run ./run for a terminal session or ./run webui for the browser UI.
  4. Optionally install Lean 4 (≈10 GiB) with bash setup.sh --with-lean if you need full proof‑assistant functionality.

Supported platforms

  • macOS Apple Silicon (arm64)
  • Linux x86_64 with glibc and AVX2

Typical workflow

mathcode -p "prove that the square of an even number is even"

The command launches an interactive session where MathCode suggests lemmas, checks them with Lean, and records the final theorem in your vault.

Documentation & community

Why it matters MathCode bridges the gap between everyday coding environments and formal mathematics. By embedding Lean verification into a familiar terminal/WebUI workflow, it makes it easier for developers and researchers to write machine‑checked proofs without leaving their usual tools.

Citation If you use MathCode in research, cite it as:

@misc{mathcode2026,
  title = {MathCode: A Frontier Mathematical Coding Agent},
  author = {Team Math-AI},
  year = {2026},
  url = "https://github.com/math-ai-org/mathcode"
}

Related

  • Project
  • Project
  • Project
  • Project
  • Project