[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"zzvhbdoV5i":3},"# Leanify\n\n**[Documentation, tutorial and live demo](https://corrram.github.io/leanify/)**\n\nOne LaTeX source, read twice: typeset as the paper you submit, and compiled by\nLean into kernel-checked statements and proofs.\n\nLeanify compiles an ordinary mathematical article, written in good\nmathematical English, to Lean. Every symbol must be defined in the article\nbefore it is used, every sentence has one fixed reading, and a proof step may\nuse only the results it cites. The kernel checks the readable Lean form of\nevery definition and claim, every justification and the final certificate; the\ncompilation of the file takes a second, and `leanify audit` has the kernel check\nthat too. There is no second, hand-written formal version that\ncould drift away from the paper.\n\n```latex\nDefine $f:(0,\\infty)\\to\\mathbb{R}$ by $f(x)\\coloneqq x+\\frac1x$.\n```\n\nbecomes the Lean definition `f := fun x => x + 1 / x`, with the obligation that\nit is well defined, `∀ (x : ℝ), 0 \u003C x → ¬x = 0`, and the theorem\n\n```latex\n\\begin{theorem}\\label{thm:bound}\nFor every $x\\in(0,\\infty)$, $f(x)\\ge2$.\n\\end{theorem}\n```\n\nbecomes `claim2 : ∀ (x : ℝ), 0 \u003C x → 2 ≤ f x`, derived in Lean from exactly the\nsentences of its proof and the lemma they cite.\n\n## Exemplars\n\nTwo articles are compiled in\n[lean-verifications](https://github.com/Corrram/lean-verifications):\n\n* *Rank weighting and asymmetry in Blest's rank correlation: two exact regions*\n  (arXiv:2609.27634), `Papers/Rockel2026ExactBlest/Source`: 37 definitions and\n  48 claims, all certified. The proof of Corollary 3.2 is checked sentence by\n  sentence against what it cites; the other results are proved through bridges to\n  the companion development.\n* *The exact region determined by Spearman's rho and Gini's gamma*\n  (arXiv:2609.19890), `Papers/AnsariRockelSteinmassl2026RhoGamma/Source`: 11\n  definitions and 8 claims, all certified.\n\nEach folder's `article-edits.diff` lists every edit the conventions asked for,\nand its README the coverage: which sentences compiled, and which are still prose.\n\n## Use\n\n[Getting started](docs/getting-started.md) takes a one-page note from a first\ndraft with four mistakes to a certificate, step by step:\n\n```sh\nlake exe leanify check Note/article.tex --claims   # undefined symbols, unread statements, the reading of every claim\nlake exe leanify init Note/article.tex             # the Lean files, with a stub proof of every claim\nlake build Note.Certified                            # the kernel checks the statements and your proofs\n```\n\nThe project needs Leanify in its `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"leanify\"\ngit = \"https://github.com/Corrram/leanify.git\"\nrev = \"main\"\n```\n\nOr start from the article alone: with the checker on the `PATH`,\n`leanify certify article.tex` makes its folder a Lean project that requires the\nLeanify of the checker, writes the Lean files, fetches mathlib and builds the\ncertificate.\n\n`leanify init` writes four files next to the article, and adds the article's\nlibrary to `lakefile.toml`:\n\n| File | Contents |\n| --- | --- |\n| `Compiled.lean` | `#leanify_article Note \"article.tex\" \"fnv1a64:…\"`: the article compiled to a Lean document, pinned by its hash (`leanify prepare` updates the pin after an edit; `leanify audit` has the kernel evaluate the compiler) |\n| `Article.lean` | `#leanify_semantics`: every definition and claim as readable Lean (`claimK`, `meaningfulK`, `obligationK`) |\n| `Proofs.lean` | your proofs `proofK : obligationK` and `definedI : wellDefinedI`, or `refuteK : meaningfulK ∧ ¬ claimK` for a claim that is false as stated, and `satisfiedK : satisfiableK`: the hypotheses of statement `K` can hold together |\n| `Certified.lean` | `#leanify_certify`: the certificate `Note.certificate`, each verified claim `Note.verifiedK`, and the reports |\n\nA proof that still uses `sorry` leaves its claim unverified, so an article can\nbe certified while its proofs are written. The certificate also reports what a\nproof alone does not show: whether the hypotheses of every claim are shown to\nhold together, and whether each step of a printed proof is closed by one fixed\ntactic (`leanify_step`) or needed a longer Lean argument. A result is marked\n*derived* only without either reservation. Two scripts take a command of yours\n(a model, usually): `scripts/leanify_suggest.py` proposes rewrites of the\nsentences Leanify cannot read, and keeps one only if the check then reads it;\n`scripts/leanify_prove.py` proves the open obligations, and writes a proof only\nif Lean accepts it. The check reads an article with the files it inputs\n(`\\input`, `\\include`, the article's own `.sty` files). Articles about probability on the\nunit square use `--vocab unitsquare` ([Vocabularies and models](docs/vocabularies.md)).\n\nThe same source gives the two readable outputs:\n\n* the PDF, with `\\usepackage{leanify}`, unchanged, or with\n  `\\usepackage[status]{leanify}` marking every result in the margin with its\n  verification status (read from `article.leanify.tex`). Compiled with shell\n  escape, the package also checks the article on every compile, with the\n  findings as LaTeX warnings at their lines, and with `certify` it builds the\n  certificate first. `\\leanifyreadings` prints the formal reading of every\n  definition and statement, so that a reader of the PDF sees what Lean was asked\n  to prove;\n* the web reader, `node reader/build.mjs article.tex`, which renders the\n  article from its source with the status of every sentence and, for each\n  claim, its formal reading, Lean statement, premises and justification.\n\nThe examples are short papers in the usual style, each certified by CI:\n\n* [`examples/Demo`](examples/Demo), the note of the guide (`draft.tex` and the\n  certified `article.tex`), and [`tests/Refuted`](tests/Refuted), the same note\n  with its theorem refuted;\n* [`examples/Means`](examples/Means), the harmonic, geometric and arithmetic\n  mean of two numbers, with symbols defined inside a theorem, in a\n  `where`-clause and in apposition. Five steps of its proofs use rules for\n  square roots that the standard tactic does not know, so its results are\n  marked *argued*, not *derived*;\n* [`tests/Arguments`](tests/Arguments), proofs with assumptions, cases,\n  contradictions and inductions, each step closed by the standard tactic;\n* [`tests/TailDependence`](tests/TailDependence), two notions of positive\n  dependence of copulas, with the field `unitsquare`; the independence copula shows\n  that the hypotheses of its proofs can be met.\n\n`bash scripts/ci.sh` runs every check of the repository, as CI does.\n\n## Documentation\n\n* [Getting started](docs/getting-started.md): set up a project, check an\n  article while writing, prove its claims, read the certificate.\n* [Writing for Leanify](docs/writing.md): the house style and the\n  constructions of the grammar, with examples.\n* [From the `.tex` file to the certificate](docs/pipeline.md): the stages,\n  incremental compilation, definedness, the citation audit, the reports and\n  the trust boundary.\n* [Vocabularies and models](docs/vocabularies.md): where the meaning of words\n  that the article does not define comes from.\n* [Status and next constructions](docs/roadmap.md): what the exemplars cover\n  and which constructions the remaining sentences need.\n\n## Layout\n\n| Path | Contents |\n| --- | --- |\n| `Leanify/Lex.lean`, `Segment.lean`, `Math.lean` | Lexing (macros, blocks), sentence segmentation, formulas |\n| `Leanify/Grammar.lean`, `Elab.lean`, `Doc.lean` | Sentence constructions and their readings, compilation of an article (`compileArticle`) |\n| `Leanify/Syntax.lean`, `Denote.lean` | The core language and its Lean denotation |\n| `Leanify/Vocab.lean`, `Library/` | Vocabularies, `phrase!`, and the fields: each is data (phrases, types and the names of their Lean meanings) |\n| `Leanify/Meta.lean`, `Readable.lean`, `Certify.lean` | The commands `#leanify_article`, `#leanify_semantics`, `#leanify_certify` |\n| `Leanify/Check.lean`, `LeanifyCli.lean` | The command line `lake exe leanify`: `check` (the native checker, with the files the article inputs), `certify` (from an article to its certificate), `audit` (the kernel evaluates the compiler), `init` (the Lean files of an article, and its project), `prepare` (the pin), `flatten` (the article and its inputs as one file), `tex` (what `leanify.sty` runs) |\n| `examples/`, `tests/` | The example articles of the documentation, and the test articles (a refuted theorem, notions in the running text), certified in CI |\n| `reader/` | The web reader: the article rendered from its source with the status of every sentence |\n| `tex/leanify.sty` | The check on every compile (with shell escape), the certificate with `certify`, and margin marks with `status` |\n| `docs/`, `mkdocs.yml` | The documentation site, https://corrram.github.io/leanify/ |\n| `scripts/leanify_diagnostics.py` | Findings from the certificate report, for editors and CI |\n| `scripts/leanify_suggest.py`, `scripts/leanify_prove.py` | A hook proposes rewrites of unread sentences, or proofs of open obligations; the checker and Lean decide |\n\n## Build\n\n```sh\nlake exe cache get\nlake build\nnpm ci && npm test\n```\n\nThe documentation site is `docs/` with `mkdocs.yml`:\n\n```sh\nnpm run demos                          # the readers of the example articles, into docs/demo/\npip install -r requirements-docs.txt\nmkdocs serve\n```\n\n`.github/workflows/pages.yml` publishes it from `main`.\n\nLean 4.34.0 with the mathlib revision in `lake-manifest.json`. The generic code\nis licensed under Apache-2.0.\n",1795286046463]