We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.
Contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to https://cla.developers.google.com/ to see your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
- Formalizing or updating a paper/work → fork and open a PR against
formal-papers-<period>(never againstformal-papers). - Extending
PaperLib/or proving an openmegatheorem→ fork and open a PR againstformal-papers.
This project follows Google's Open Source Community Guidelines.
All submissions to Google Open Source projects need to follow Google's Contributor License Agreement (CLA), which covers any original work of authorship included in the submission. This doesn't prohibit the use of coding assistance tools, including tool-, AI-, or machine-generated code, as long as these submissions abide by the CLA's requirements.
AI-integrated tools must not be listed as commit authors or co-authors (for example, in Co-Authored-By: trailers), and the origins of submitted material must not be misrepresented.
- All code and documentation in Git are licensed under the Apache License, Version 2.0. Retain existing copyright and license notices, and include the Apache-2.0 header on new
.leanfiles (Released under Apache 2.0 license as described in the file LICENSE.). - Third-party sources must carry a permissive license (
CC BY 4.0/3.0/2.5/2.0/1.0,CC0 1.0,CC-PDM-1.0,CC-PDDC,Apache-2.0,MIT,BSD-2-Clause,BSD-3-Clause, or public domain) with required attribution inREADME.mdand.leanheaders, or be your ownarXiv-1.0paper contributed as an author or copyright holder under the Google CLA. Excluded: third-partyarXiv-1.0,CC BY-NC*,CC BY-ND*,CC BY-SA*, copyleft licenses (GPL,LGPL,AGPL,MPL), all-rights-reserved manuscripts, and empirical/survey texts with no mathematical theorems. - Never commit raw manuscript source files. Stage arXiv / LaTeX / PDF sources locally in gitignored
.source/only, verify.source/(and anysource/folder) is absent fromgit statusand the PR diff, and link the canonical URL informalization.yaml.
git (>= 2.25), curl, python3 (>= 3.10), and elan (curl https://elan.lean-lang.org/elan-init.sh -sSf | sh).
- Google Antigravity: Clone
formal-papersand open it in Antigravity so.agents/skills/load automatically, then run/formalize https://arxiv.org/abs/<id>. - Any other coding agent (Claude Code, Codex, Gemini CLI, Cursor — replace
<arxiv-id>with an unformalized target paper, e.g.2407.14091is already formalized):Fetch https://raw.githubusercontent.com/google-deepmind/formal-papers/main/CONTRIBUTING.md and follow the step-by-step workflow to formalize and contribute paper <arxiv-id>. - Standalone preflight check (checks tools,
ghauth, duplicates, open PRs, and arXiv license before cloning):curl -fsSL https://raw.githubusercontent.com/google-deepmind/formal-papers/main/scripts/doctor.py \ -o /tmp/formal_papers_doctor.py python3 /tmp/formal_papers_doctor.py check --arxiv <arxiv-id>
Replace formal-papers-2024 and 2407.14091 with your target period repository and arXiv ID (for non-arXiv works, pass --slug <slug> --year <yyyy> --category {journals,books,other} --url <canonical-url> to scripts/new_work.py):
git clone --filter=blob:none --sparse https://github.com/google-deepmind/formal-papers-2024
python3 path/to/formal-papers/scripts/new_work.py --arxiv 2407.14091 --out formal-papers-2024
cd formal-papers-2024/arxiv/2407.14091 && lake exe cache get && lake build
# Edit Papers/arxiv_2407_14091/*.leanBefore pushing, verify diff hygiene and use .github/pull_request_template.md for the PR body:
python3 path/to/formal-papers/scripts/doctor.py check-pr --repo-dir formal-papers-2024 --arxiv 2407.14091
git push --force-with-lease -u origin formalize/arxiv-2407.14091Detailed step-by-step workflow (fork, sparse checkout, scaffold, audit, and PR gates)
For cold-start coding agents started outside the repo: clone into the current workspace (e.g.,
./formal-papers-2024), not/tmp. Act via your human's GitHub fork (--force-with-lease), pause for human-only actions (gh auth login, confirming authorship onarXiv-1.0, signing the Google CLA), readAGENTS.mdand.agents/skills/formalize/SKILL.mddirectly via file-read tools, and build touched targets with scopedlake build --no-ansi -q.
Directory layout: For 2000 onward (formal-papers-2000..2026), works live at {arxiv,journals,books,other}/<id-or-slug>/. For decade, century, and pre1500 repos, works live at <year>/{arxiv,journals,books,other}/<id-or-slug>/.
set -euo pipefail
PAPER_ID="2407.14091" # replace with target arXiv ID (e.g. 2407.14091 or math/0405341)
curl -fsSL https://raw.githubusercontent.com/google-deepmind/formal-papers/main/scripts/doctor.py \
-o /tmp/formal_papers_doctor.py
python3 /tmp/formal_papers_doctor.py check --arxiv "$PAPER_ID"(For a non-arXiv work, pass --slug <my-slug> --year <YYYY> --category {journals,books,other} instead of --arxiv.)
Stop if existing_paper, open_prs, or arxiv_license reports FAIL. If gh is not authenticated, ask your human to run gh auth login. If arxiv_license reports WARN (arXiv-1.0), confirm your human holds copyright before continuing.
Extract the routing variables:
eval "$(python3 /tmp/formal_papers_doctor.py route --arxiv "$PAPER_ID" --json | python3 -c '
import json, shlex, sys
r = json.load(sys.stdin)
for k, v in [("TARGET_REPO", r["target_repo"]), ("TARGET_REPO_NAME", r["target_repo_name"]),
("SUBDIR", r["subdir"]), ("MOD_ID", r["mod_id"]), ("BRANCH", r["branch"])]:
print(f"{k}={shlex.quote(str(v))}")
')"GH_USER="$(gh api user --jq .login)"
gh repo fork "$TARGET_REPO" --clone=false
git clone --filter=blob:none --no-checkout "https://github.com/$GH_USER/$TARGET_REPO_NAME.git" "./$TARGET_REPO_NAME"
cd "./$TARGET_REPO_NAME"
git remote add upstream "https://github.com/$TARGET_REPO.git"
git fetch upstream main
git sparse-checkout init --cone
git sparse-checkout set "$SUBDIR"
git checkout -b "$BRANCH" upstream/mainNever compile Mathlib, TauCeti, or PaperLib from scratch:
REPO_DIR="$(pwd)"
python3 /tmp/formal_papers_doctor.py scaffold --arxiv "$PAPER_ID" --repo-dir "$REPO_DIR"
cd "$REPO_DIR/$SUBDIR"
lake exe cache get
FP_DIR="$(for d in .lake/packages/PaperLib .lake/packages/FormalPapers .lake/packages/formal-papers; do [ -d "$d" ] && printf '%s\n' "$d" && break; done)"(If Lake's --filter=tree:0 clone stalls on PaperLib, pre-clone .lake/packages/PaperLib with git clone --depth=1 --branch v4.36.0 https://github.com/google-deepmind/formal-papers.git .lake/packages/PaperLib and re-run lake exe cache get. On older pins lacking lake exe cache get, run lake resolve-deps && bash "$FP_DIR/scripts/fetch_lake_cache.sh" --root ..)
python3 "$FP_DIR/scripts/prepare_source.py" --arxiv "$PAPER_ID" --out-dir .source
# Print exact CC BY / CC0 attribution headers (if required by the paper's license)
python3 "$FP_DIR/scripts/prepare_source.py" --offline --out-dir .source --print-attributionConfirm git status --ignored shows .source/ as ignored.
- Read
"$FP_DIR/AGENTS.md"and"$FP_DIR/.agents/skills/formalize/SKILL.md". - Map all compiled definitions, theorems, and figures up to
\end{document}:python3 "$FP_DIR/scripts/tex_outline.py" .source --out .lake/tex_map.md - Search existing declarations before defining anything new:
python3 "$FP_DIR/scripts/search_paper_lib.py" --repo-root "$FP_DIR" --carriers <Concept> python3 "$FP_DIR/scripts/search_paper_lib.py" --repo-root "$FP_DIR" --topics <Area>
- Implement under
Papers/$MOD_ID/*.lean(moduleheader, 100% insidenamespace Papers.$MOD_ID, noPapers/$MOD_ID.leanumbrella file,0sorry, standard Lean axioms + documentedPaperLibmegatheorems, non-vacuity witnesses, totalization guards, attribution header if required). Author standaloneREADME.md(arXiv:<id>vN,## Source & Attribution, section map,## Formalization Notes; do not hand-authorstatus.axioms). - Review every elaborated declaration (
#check @decl), definition body,#print axiomsfootprint, andREADME.mdagainst the compiled source in.source/.
Inside "$REPO_DIR/$SUBDIR":
python3 "$FP_DIR/scripts/fix_lean_lint.py" --check "Papers/$MOD_ID"
lake build --no-ansi -q
lake exe runLinter --no-build "Papers.$MOD_ID"
lake exe module-system "Papers.$MOD_ID"
lake exe axioms --root Papers
python3 "$FP_DIR/scripts/check_source_options.py" "Papers/$MOD_ID"
python3 "$FP_DIR/scripts/formalization_yaml.py" validate formalization.yaml
python3 "$FP_DIR/scripts/doctor.py" check-pr --repo-dir "$REPO_DIR" --arxiv "$PAPER_ID"cd "$REPO_DIR"
git add "$SUBDIR"
python3 "$REPO_DIR/$SUBDIR/$FP_DIR/scripts/doctor.py" check-pr --repo-dir "$REPO_DIR" --arxiv "$PAPER_ID"
git commit -m "Formalize arXiv:$PAPER_ID"
git push --force-with-lease -u origin "$BRANCH"Fill out "$REPO_DIR/$SUBDIR/.lake/pr_body.md" from "$REPO_DIR/$SUBDIR/$FP_DIR/.github/pull_request_template.md" (gh pr create --body-file does not auto-apply GitHub templates), then open the PR:
gh pr create \
--repo "$TARGET_REPO" \
--base main \
--head "$GH_USER:$BRANCH" \
--title "Formalize arXiv:$PAPER_ID: <Short Paper Title>" \
--body-file "$REPO_DIR/$SUBDIR/.lake/pr_body.md"git clone --filter=blob:none https://github.com/google-deepmind/formal-papers
cd formal-papers && bash scripts/bootstrap.sh
# Optional: `lake exe cache get` also downloads the prebuilt PaperLib cache
# Search first: python3 scripts/search_paper_lib.py --carriers <Concept>
# Edit PaperLib/<Area>/<Subarea>/<Mod>.lean (+ companion annotations/PaperLib/ JSONL)
python3 scripts/check_annotations.py
python3 scripts/reverse_cone_ci.py --diff-base origin/main --execute
python3 scripts/pre_commit.pyCompanion annotations under annotations/PaperLib/ follow the literature-links JSONL schema. Open a PR from your fork against formal-papers main using .github/pull_request_template.md.
See AGENTS.md for the canonical workspace rules (search-before-defining, namespaces, sorry-free and standard Lean axioms, PaperLib airgap, non-vacuity and totalization checks, and verification gates).