Tex2Lean tutorials

Choose the guide for your editor or terminal.

Formalize your first result from the terminal.

Start with your paper’s LaTeX sources. You’ll connect a model, choose one result, review its Lean statement, and check the proof evidence.

This walkthrough uses the interactive Tex2Lean session. Enter each command separately and wait for it to finish before continuing.

  1. Install Tex2Lean
  2. Open your paper
  3. Connect a model
  4. Prepare Lean
  5. Scan and choose a result
  6. Start formalizing
  7. Review the statement
  8. Follow, pause, and resume
  9. Check what was proved

STEP 01

Install Tex2Lean

Have Git installed and your paper’s source folder ready. You’ll also need internet access, several gigabytes for Lean libraries, and a model connection (chosen in step 3). Tex2Lean sets up Lean.

If you have Node.js 22.14 or newer, open your usual terminal and install the CLI:

In your terminal

npm install -g tex2lean
Install without Node.js

The standalone installer includes its own runtime. On macOS or Linux:

curl -fsSL \
https://raw.githubusercontent.com/meelgroup/tex2lean-releases/main/install.sh \
| sh

On Windows, use PowerShell:

irm `
https://raw.githubusercontent.com/meelgroup/tex2lean-releases/main/install.ps1 `
| iex

The installers verify the release checksum. On macOS and Linux, ensure ~/.local/bin is on your PATH. Manual downloads are also available.

Check that your terminal can find Tex2Lean:

tex2lean --version

Ready to continue: a version number appears. If the command is not found, reopen your terminal and check the installation directory is on your PATH.

STEP 02

Open your paper’s folder

Use the folder containing the main .tex file and its included sources. Replace the example path with your folder’s path; keep the quotes if it contains spaces.

In your terminal

cd "/path/to/your/paper"
tex2lean

Tex2Lean opens an interactive session. Its input stays at the bottom while the transcript appears above. Type commands beginning with / into that input and press Enter.

Ready to continue: you can enter /help and see the available commands. From this point, the command boxes are for the Tex2Lean input, rather than your shell.

My session looks different

Terminals without fullscreen support use a plain prompt. The slash commands still apply. If you are back at your shell, run tex2lean again from the paper folder.

You can also choose the folder explicitly from your shell with tex2lean --project "/path/to/your/paper".

STEP 03

Connect the model you want to use

In Tex2Lean

/connect

Follow the connection questions. Choose your signed-in Claude Code or Codex CLI, or configure a supported API provider. If you select a coding CLI, install it and sign in before continuing. OpenRouter can run proof agents with local file and Lean tools without a separate coding CLI.

For a menu, move between choices with the arrow keys and confirm the highlighted action with Enter. Enter credentials in the credential prompt when requested. API usage is billed by your provider; subscription access follows your CLI’s allowance.

Ready to continue: the connection is configured and the command finishes. Resolve any authentication error before starting formalization.

STEP 04

Prepare the Lean environment

In Tex2Lean

/setup

Answer the setup questions and let Tex2Lean prepare Lean, Mathlib, and arlib. Initial downloads and library builds can take time. Read the progress and any action requested in the transcript.

Ready to continue: setup completes successfully. If it fails, inspect /log, address the reported problem, and run /setup again. Complete setup before moving on to the paper scan.

STEP 05

Scan your paper and choose one result

In Tex2Lean, one command at a time

/scan
/targets

If asked which file is the paper, choose the main LaTeX file that includes the other chapters or sections. Read the result list: it shows identifiers, labels, status, and source locations when recorded. Choose one theorem or lemma for your first run.

Copy that result’s identifier exactly. The rest of this guide uses t1 as a placeholder: replace it in every command with your actual identifier. To locate the statement in the paper:

/show t1

Open the reported source location and confirm it is the result you intend to formalize.

Ready to continue: you have one result identifier and have checked its statement in your paper. If the wrong paper was scanned or no results appear, use /rescan to choose the main file again.

STEP 06

Start formalizing that result

Keep statement review enabled for this walkthrough. Autonomy is a saved project preference, so turn it off explicitly for this run.

In Tex2Lean, one command at a time

/autonomy off
/formalize t1

Tex2Lean prepares the mathematical definitions, algorithm when relevant, and Lean theorem for the chosen result. Watch the transcript and answer any questions about the intended statement. A question takes focus until you answer it.

If you prefer to choose from a list, /formalize without an identifier offers a result picker. You do not need to run separate planning and proving commands for this workflow.

Next: when the statement review question appears, leave it open and follow step 7 before choosing to start proving. If an earlier question needs your input, answer that first.

STEP 07

Review the actual Lean statement

The review question lists the Lean files that state your model and theorem. Open those files in your preferred editor alongside the original paper. The Lean project folder is recorded in formalize.json; a new project normally uses lean/, or a numbered alternative if that name is taken. Follow the paths shown for your project.

Before approving, compare these parts with the paper:

  • Inputs and definitions: do the objects, domains, and mathematical model describe the same problem?
  • Algorithm: do the modeled operations and output match the paper’s pseudocode?
  • Hypotheses and quantifiers: are parameter restrictions and “for every” or “there exists” claims correct?
  • Conclusion: are the guarantees, probability bounds, and time or space claims the ones you intended?
  • Prior work: are any borrowed results explicit assumptions, with the expected meaning and source?

If it matches: choose Start proving in the review menu and press Enter.

If it needs a correction: choose I want to edit it first. Once the run is held, edit and save the listed Lean files, then enter /resume. You can also request a correction in words with /change, for example:

In Tex2Lean, while held for review

/change Use the input domain in Section 2.

Replace that example with the specific mismatch you found. Review the resulting files and follow the next review or resume prompt. A note typed without /change is a worker instruction; it does not itself apply a checked edit to the statement.

Ready to continue: you have reviewed the written theorem and allowed proof work to begin. Lean will check this encoded statement, so matching it to the paper is an essential part of the process.

STEP 08

Follow the proof, pause, and resume

After review, Tex2Lean works on the interfaces and proofs needed for your result. Progress may include file edits, Lean builds, and unresolved goals. Let it continue, or inspect its activity:

In Tex2Lean

/status

Use /log for recent diagnostics. You can type a note such as “Use the notation from Section 2” into the normal input; it is saved for workers at their next boundary.

If a question proposes changing the statement, compare the proposed change with your paper before answering. Accepting a weaker or differently scoped statement changes what is proved.

To pause from the fullscreen session, enter:

/pause

Or press Esc when no question is open. Wait for active work to settle before editing files or starting another project command. /stop or Ctrl+C stops active work while keeping the session open. Generated files are retained.

Continue saved work, selecting your result if prompted:

/resume

If you have closed the terminal, reopen it in the same paper folder, run tex2lean, then enter that resume command. Pause the active run before switching between CLI and VS Code; only one run can own the project at a time.

Next: when the run finishes or reports a blocker, inspect the result with step 9. A finished command or a successful build alone is not proof completion.

STEP 09

Check what was actually proved

With the run idle, enter each command separately and read its report before continuing:

In Tex2Lean, one command at a time

/targets
/lean t1
/check
/proved
/handoff
  1. Find the result. /targets shows its recorded status. /lean t1 locates the Lean files and declaration carrying that result.
  2. Read the mechanical checks. /check inspects the build and proof obligations. Investigate remaining sorry placeholders, failures, or outstanding goals rather than treating a build as sufficient.
  3. Read the theorem’s assumptions. /proved asks Lean what finished theorems rest on. Find your chosen result. sorryAx signals an unfinished proof. Distinguish standard Lean axioms from additional assumptions; explicit Prior hypotheses mean the result is conditional on those borrowed results.
  4. Compare with the paper. /handoff produces a comparison report. Read its findings alongside the Lean statement and paper; resolve discrepancies before describing the paper’s result as verified.

Your first-run outcome: you can locate the Lean theorem, read its current proof evidence, and explain any remaining obligations or assumptions. If a run is incomplete, use its diagnostics and /resume to continue; proof completion is not guaranteed.

When finished, enter /quit to leave Tex2Lean.

After your first result

Run with autonomy or work on several results

After choosing the model, paper root, and result, enable the project preference with /autonomy on, then run /formalize t1. Use /autonomy status to inspect the preference and /autonomy off to restore manual review.

Autonomy supplies declared answers to routine questions, including statement review. Author decisions such as major statement changes can still stop a run. It does not authorize publishing. The preference is shared with VS Code.

/all offers to work through outstanding results in dependency order and skips planning review after confirmation. Start with a reviewed single result before using this workflow.

Use commands directly from your shell

Outside the interactive session, replace the leading slash with tex2lean . For example, /scan becomes tex2lean scan. Run these separately from your paper folder, answering each command’s prompts before continuing:

tex2lean connect
tex2lean setup
tex2lean scan
tex2lean targets
tex2lean formalize t1

For direct runs, p requests a pause and Ctrl+C stops work. Continue with tex2lean resume t1. The same statement review and final checks apply.

tex2lean formalize t1 --autonomous enables autonomy for one invocation. --yes takes the first offered action where permitted; it differs from autonomy’s declared answers. plan is a compatibility alias for formalize; prove works on an existing plan.

Keyboard shortcuts, configuration, and updates

At the input, Tab completes slash commands and up/down recalls command history. PageUp and PageDown scroll the fullscreen transcript. When idle, Ctrl+C clears your draft; on empty input it exits. During a question, follow that question’s keyboard hints.

From your shell, use --project DIR to choose a paper folder, --agents N for worker concurrency, and --provider NAME for a model connection. tex2lean --help lists supported options.

Update npm installs with npm install -g tex2lean@latest. For standalone installs, use tex2lean upgrade.

If you get stuck

  • “Not set up” or “not connected”: finish /setup or /connect, then retry the command that was blocked.
  • No matching result: use /targets and copy the exact identifier rather than the example t1.
  • Another run owns the project: pause the active CLI or VS Code run and wait for cleanup before retrying.
  • A command failed: read /log for the reported cause. For a bug report, include your tex2lean --version, the command, and a relevant log excerpt after removing private information.

Report a problem · CLI downloads and installation reference