formalize

A workflow for expressing ordinary mathematics as Lean 4 code and making Lean verify the proof. Lean 4 is a programming language and proof checker, while Mathlib is its library of mathematical results.

In plain words
What is it for?
Use it for mathematical claims, definitions, exercises, conjectures, or questions about how to state and prove something in Lean.
Why use it?
It turns informal claims into precise statements and catches missing assumptions or errors through compilation. The workflow also guides the user through understanding the claim before writing code.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/nasqret/lean-interact/formalize
Any agent
npx skills add nasqret/lean-interact --skill formalize
Clone the repo
git clone --depth 1 https://github.com/nasqret/lean-interact

Made for: Claude Code, Codex.

Per session 168 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,398 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00168 $0.04398
Opus 5 $0.00084 $0.02199
Sonnet 5 $0.00034 $0.00880
Haiku 4.5 $0.00017 $0.00440

Measured 3d ago against content hash 4f6a803e68ff, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

formalize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/formalize/SKILL.md · 315 lines

How it starts

The opening of the file, as written. The whole thing — 315 lines — stays where its author put it; the contents beside it link to each section on GitHub.

formalize

The core loop of this repository. The user — a working mathematician who knows the mathematics and is learning Lean — types a sentence of ordinary mathematics; you return compiled Lean plus a short teaching note.

Repository root: /path/to/lean-interact, the directory this clone lives in. Use absolute paths when reading and editing files. Run the tools/ scripts from the repository root with repo-relative paths (python3 tools/mlq.py …): that is the form .claude/settings.json allows without a permission prompt, and it is the form to show the user.

Before the first formalization of a session, read MEMORY.md and vault/Formalization Style.md. They contain decisions you would otherwise contradict.

Run the steps in order. Do not skip steps because the claim looks easy; the cheap steps are the ones that prevent the expensive mistakes.


Step 1 - UNDERSTAND

Restate the claim as precise mathematics before touching any file. Make explicit, in one short paragraph:

  • every quantifier and its range;
  • every hypothesis, including the ones ordinary prose leaves silent (p prime often means odd; "a/b" often means b ∣ a; "the order of a" presupposes gcd(a, n) = 1);
  • the ambient type.

Choose the ambient type using vault/Nat vs Int vs ZMod.md. If that note is not present yet, use the table in vault/Formalization Style.md section 1. The short version:

The claim is about Type
counting, divisibility, gcd, primes, no subtraction , with Nat.ModEq for congruences
genuine differences, negatives, Bezout coefficients , with Int.ModEq
a fixed numeral modulus, ring or unit structure mod n, squares, orders ZMod n
a quantified modulus n Nat.ModEq / Int.ModEq, never ZMod n (dependent type pain)

Ambiguity rule. Ask at most ONE short question, and only if the answer would change the statement. Otherwise state the assumption in one clause and continue: "Taking n > 0 and a coprime to n; say if you meant otherwise." Never open a formalization with a list of questions.

Read the full file on GitHub · 315 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 315 lines · 168 tokens per session scan A 4f6a803e68ff

Subscribe to this mod's changes

formalize is a skill published in the GitHub repository nasqret/lean-interact (10 stars, last pushed 25d ago), licensed MIT. It adds 168 tokens to every session and 4,398 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

mathlib-api

Evidence-driven workflow for designing a Mathlib definition and the API around it. Use when adding a new structure/def intended for mathlib; when choosing between design alternatives (index type as field vs parameter, Set vs indexed family, coarse set vs finer indexed structure and when the fine one should exist at…

homeowmorphism/mathlib-api · 234 tokens

lean-probe

Fast Lean 4 proof verification for coding agents via the LeanProbe MCP server's warm REPL. Use when you need to know whether Lean 4 code compiles (no errors, no sorry), iterate on a declaration inside a Lake/Mathlib project, test a replacement proof candidate, or explore a goal tactic by tactic — far faster than lake…

epfl-lara/LeanProbe · 139 tokens

screen

Screen informal↔Lean 4 statement pairs for faithfulness defects. Use whenever writing, editing, translating, or reviewing Lean 4 theorem or definition statements that are meant to formalize informal mathematics: after drafting a statement, before committing formalizations, when auditing a benchmark file, or when the…

ibrahimmian36/leanscreen · 0 tokens

learn-from-math-agent-trajectories

Review completed or paused mathematical agent transcripts, visible reasoning, code, searches, tool calls, corrections, and final claims to extract evidence-backed lessons for Jacobian operations, discovery, contracts, skills, evaluations, and documentation. Use for mathematical workflow retrospectives and "what should…

morluto/jacobian · 87 tokens

decompose-mathematical-solution-corpora

Decompose a bounded corpus of mathematical proofs, formalizations, scripts, and certificates into recurring solution techniques and the smallest reusable Jacobian postconditions. Use for repository- or corpus-level “what can Jacobian learn?” audits; do not use for one operation contract or one agent trajectory.

morluto/jacobian · 69 tokens

verifier-evaluations

Design, audit, and repair fail-closed mathematical verifiers and evaluation contracts, including public schemas, frozen-input binding, task-specific witnesses, diagnostic scoring, adversarial fixtures, and Oracle validation. Use when a verifier can crash, accept malformed claims, reject equivalent witnesses, leak…

morluto/jacobian · 68 tokens