← all repositories
math-ai-org/mathcode

Your Math Intuition, Compiled to Lean 4

MathCode is a terminal AI assistant that converts plain-language math problems into formal Lean 4 theorems and attempts to prove them, complete with a persistent REPL and reusable theorem library.

742 stars Shell Coding AssistantsAgents
mathcode
Velocity · 7d
+0.9
★ / day
Trend
steady
star history

What it does MathCode is a terminal AI assistant that treats informal math as input for a proof assistant. Describe a problem in plain English and it generates a Lean 4 theorem statement, then attempts a formal proof. Output lands in LeanFormalizations/ and is validated through an integrated persistent REPL.

The interesting bit The project treats the gap between informal reasoning and formal proof as a compilation target. After a one-time ~90 second warmup to import Mathlib, its persistent Lean REPL drops compile checks to about 0.4 seconds—down from roughly 30—making the feedback loop tight enough to iterate with an LLM on formal logic.

Key highlights

  • Persistent Lean REPL that imports Mathlib and your theorem library for sub-second compile checks after a one-time warmup
  • Automatic theorem library that names, stores, and imports successfully proved theorems for reuse in later sessions
  • Terminal-first interface with an optional browser UI, using the codex CLI as the default backend
  • Extensive session machinery including context compaction, task management, and custom agent definitions with trimmed prompts and normalized skill lists
  • Platform support limited to macOS arm64 and Linux x86_64

Caveats

  • Requires the codex CLI for the default backend and standard math flow
  • The persistent REPL needs roughly ninety seconds and significant disk space for the Lean toolchain and Mathlib caches
  • Optional Python 3.12+ is only needed for analysis tools in the tools/ directory

Verdict Mathematicians, proof engineers, and AI researchers looking to automate the busywork of Lean 4 formalization should take a look. If you do not work with proof assistants or lack the patience for a one-time heavyweight setup, this is not your tool.

Frequently asked

What is math-ai-org/mathcode?
MathCode is a terminal AI assistant that converts plain-language math problems into formal Lean 4 theorems and attempts to prove them, complete with a persistent REPL and reusable theorem library.
Is mathcode open source?
Yes — math-ai-org/mathcode is open source, released under the Apache-2.0 license.
What language is mathcode written in?
math-ai-org/mathcode is primarily written in Shell.
How popular is mathcode?
math-ai-org/mathcode has 742 stars on GitHub and is currently holding steady.
Where can I find mathcode?
math-ai-org/mathcode is on GitHub at https://github.com/math-ai-org/mathcode.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.