Formalization is the process of converting informal mathematical statements — theorems, definitions, proofs written in natural language or symbolic notation — into machine-checked Lean 4 code. OpenGauss provides two formalization commands that spawn managed backend agents to do this work inside your active Lean project:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/math-inc/OpenGauss/llms.txt
Use this file to discover all available pages before exploring further.
/formalize for an interactive, user-guided session and /autoformalize for an autonomous run that proceeds without step-by-step guidance.
The two modes
/formalize — interactive
/formalize launches a managed backend session where you and the agent work together. The agent opens Claude Code (or Codex) in your project root and begins the lean4:formalize workflow, but it pauses to ask for clarification, suggest alternatives, and incorporate your feedback at each stage. Use this mode when the mathematical content is nuanced or when you want direct control over naming, style, and theorem boundaries.
/autoformalize — autonomous
/autoformalize hands the entire task to the agent. It spawns the same managed backend but runs the lean4:autoformalize workflow end-to-end without stopping for confirmation. Use this mode for well-scoped statements where you trust the agent to make reasonable decisions, or when running in a batch context.
Both commands delegate their proving and formalization behavior to the
cameronfreer/lean4-skills project. OpenGauss handles project detection, backend staging, MCP wiring, and swarm tracking — the mathematical workflow logic lives in lean4-skills.How the managed backend works
When you run/formalize or /autoformalize, OpenGauss:
- Discovers the active Gauss project by walking upward from your current directory to find
.gauss/project.yaml. - Stages the
lean4-skillsassets (cloned into~/.gauss/autoformalize/assets/) and thelean-lsp-mcpMCP server. - Prepares a managed backend home directory with credentials, MCP config, and a startup context file.
- Spawns a child session — Claude Code or Codex — in the Lean project root, injecting the startup context as the initial prompt.
- The child session runs
/lean4:formalizeor/lean4:autoformalizeinside the active Lean project. - The task appears in
/swarmwhere you can monitor it, reattach to it, or cancel it.
/prove forwards to /lean4:prove, /draft to /lean4:draft, /review to /lean4:review, and so on.
Typical formalization workflow
Run the formalization command
Pass the mathematical statement directly as a string argument:Or target a specific file in your project:
The agent opens Claude Code in your project root
Gauss stages the
lean4-skills plugin and MCP server, then launches Claude Code
with the startup context injected. Claude Code immediately runs
/lean4:formalize (or /lean4:autoformalize) as its first action.For the interactive /formalize mode you’ll see the agent’s progress in the
spawned session and can provide guidance. For /autoformalize the agent runs
fully autonomously.The prove / autoprove distinction
The same interactive vs. autonomous pattern applies to the proving commands:| Command | Mode | Backend |
|---|---|---|
/prove [scope or flags] | Interactive — you guide the agent | /lean4:prove |
/autoprove [scope or flags] | Autonomous — agent works independently | /lean4:autoprove |
/formalize [topic or flags] | Interactive formalization | /lean4:formalize |
/autoformalize [topic or flags] | Autonomous formalization | /lean4:autoformalize |
/draft, /review, /refactor, /golf, and /checkpoint are available for the full Lean workflow lifecycle. All commands follow the same pattern: Gauss spawns a managed backend child session and forwards the argument tail to the corresponding lean4-skills workflow command.
Backend requirements
OpenGauss supports two managed workflow backends:- claude-code (default)
- codex
The default backend. Requires the Claude Code CLI installed and authenticated:Or save an
ANTHROPIC_API_KEY in ~/.gauss/.env. When both local Claude
credentials and a saved API key are present, Gauss prefers the local credentials.You can control auth behavior with gauss.autoformalize.auth_mode in
~/.gauss/config.yaml:git— for staginglean4-skillsassetsuvoruvx— for running thelean-lsp-mcpMCP serverrg(ripgrep) — for Lean local search in the workflow- An active Gauss project (
gauss doctorreports all of these)
Passing flags through
Any text after the command name is forwarded verbatim as the argument tail to the backendlean4-skills command. This lets you pass lean4-skills-specific flags without any special Gauss syntax:
Example session
Here is what a typical interactive/formalize session looks like: