lean2js
API documentation for every module of this package, generated from the compiled environment. Declarations link to their pinned source; an import of a dependency links to that dependency's source at the revision this package is built against.
A compiler for carrying business logic proved in Lean 4 to JavaScript / TypeScript as an ordinary npm
package. This site is the reference for the modules of Lean2Js and the theorems and definitions in
them; the source is the repository on GitHub.
Where to start reading:
Lean2Js.Core— the syntax of the Lean subset that is carried to JSLean2Js.Reify— walks a user'sdef, building the Core term and the proof that this AST denotes that function in the same pass.Lean2Js.Denoteshas the lemma for each formLean2Js.Eval— the reference semantics of the subset. Every guarantee is stated as agreement with itLean2Js.Compile— Core to JS, type-checking and generating in a single passLean2Js.Correct/Lean2Js.Sound/Lean2Js.Decl— compiler correctness, type soundness, and the statements made per public functionLean2Js.Example— the program that ships, and the theorems about it
How the proofs, the run-time checks and the differential run on Node fit together is in how the guarantee is assembled.
- Modules
- 50
- Declarations
- 4,157
- Lean
- 4.33.1
Modules
- Lean2JsWhat a user's package gets from
import Lean2Js - Lean2Js.AgreeRuntime agreement between the reference semantics and the model of the generated JS
- Lean2Js.AxiomsPins the axioms every shipped theorem is allowed to rest on
- Lean2Js.BoundHow big a thing a program can ask a value to size
- Lean2Js.BuilderNotation for writing Core terms
- Lean2Js.ChecksWhat this repository checks about itself and a user never builds
- Lean2Js.CompileCore to JS, type checking and code generation in one pass
- Lean2Js.CoreThe syntax of the Lean subset destined for JavaScript
- Lean2Js.CorrectCompiler correctness for a fragment of the subset
- Lean2Js.CostHow much fuel a program can possibly need
- Lean2Js.DeclCorrectness at the boundary a caller crosses: one public function
- Lean2Js.DenoteAn author's theorem as a claim about the shipped JavaScript
- Lean2Js.DenotesWhat one
Core.Exprclaims about one ordinary Lean term - Lean2Js.DtsWhat the
.d.tssays a value is, against the entry check the generated code runs - Lean2Js.EmitWriting a manifest out as an npm package
- Lean2Js.EncWhere an ordinary Lean type sits inside
Value - Lean2Js.EncDeriving
deriving Encfor the types an author declares - Lean2Js.EvalThe reference semantics of the subset, as a fuelled big-step evaluator
- Lean2Js.ExampleBusiness logic written in Lean, and the theorems proved about it
- Lean2Js.ExhaustiveA
matchthe compiler accepted has an arm for every value of its scrutinee - Lean2Js.ExpandVocabulary written where it is called
- Lean2Js.FuelTaking fuel out of the claims: more of it never changes an answer
- Lean2Js.GatherWhat a package is made of
- Lean2Js.HelperThe runtime helpers the generated code calls, held as a tree
- Lean2Js.HelperAgreeThe helper table the model assumes, proved against the source that ships
- Lean2Js.HelperProofWhat each runtime helper computes, read off the tree the printer writes
- Lean2Js.HelperSemThe semantics of the fragment the runtime helpers are written in
- Lean2Js.IdentWhether a name is safe as an identifier in the generated JS
- Lean2Js.JsThe AST of the JavaScript to emit, and the ESM and
.d.tsprinters - Lean2Js.JsSemThe semantics of the generated JavaScript, held inside Lean
- Lean2Js.JsonA minimal JSON writer for the proof manifest and the test vectors
- Lean2Js.ManifestThe proof manifest that accompanies the artifact
- Lean2Js.NodeCheckHolding the artifact against the real JavaScript engine before it is written
- Lean2Js.NormThe shapes of
Js.normTy,Js.outTyandJs.checkFields, unfolded once each - Lean2Js.ParseA reader for the text the printers write
- Lean2Js.PreludeThe functions an author writes where Lean's own would mean something else
- Lean2Js.ProbeTrying a shipped theorem's hypotheses at an argument
- Lean2Js.ReifyA reifier that emits the certificate along with the AST
- Lean2Js.RenderableThat the compiler only builds modules the reader takes back
- Lean2Js.RoundtripThat the reader gives the printer's input back
- Lean2Js.Sha256SHA-256
- Lean2Js.SoundType soundness: a value
evalreturns satisfies the type the compiler read - Lean2Js.StepThe small-step semantics, as an abstract machine with explicit continuations
- Lean2Js.StepAgreeThe small-step machine answers what
evalanswers - Lean2Js.TestsThe programs the compiler must not accept
- Lean2Js.TextDecimal numerals and JS / JSON string escaping, for the printers
- Lean2Js.TrapsWhich traps one exported function can actually reach
- Lean2Js.ValueThe values
evalreturns, and the traps that line the semantics up with JS - Lean2Js.VectorsThe inputs of the differential test and the values
evalmust return - Lean2Js.VerifiedWhat an author writes next to a
def