Explanation
Understand why Lema exists, how a Lema program fits together from pure data to host capabilities, and how the content-addressed store, VM, and proved HTTPS stack work.
The pages in this section explain the ideas and architecture behind Lema. You do not need a background in functional programming, type theory, or interactive theorem provers to read them. Each page introduces one part of the system from first principles before connecting it to the rest of the platform.
How this section is organized
- The core mental model (
1 to 5) starts with Build software like mathematics and Anatomy of a Lema program, then looks closer at Types and invariants, Contracts, selections and proofs, and Code stored by identity.
- Interactive systems and the stack (
6 to 8) covers how programs evolve and run concurrently in Evolving programs, handles and concurrency, how Lema talks to the operating system in Capabilities and the host boundary, and how storage, cryptography, TLS 1.3, HTTP/1.1, and S3 are built inside Lema in The proved storage and HTTPS stack.
- Execution, acceptance, and team workflow (
9 to 13) traces how store objects compile and run in The compiler and VM, how the Lean kernel checks submissions in How the store accepts code, how Lema separates Checked, tested and assumed guarantees, and how teams and AI agents collaborate through Semantic version control and Lema Cloud and LemaHub.
- Status, lineage, and history (
14 to 16) records current Version and compatibility boundaries, compares Lema with Lean, Unison, and Bend in Where the ideas come from, and summarizes the numbered Design decisions.
- Build software like mathematics Why AI-generated code changes the economics of software engineering, how human-readable contracts pair with agent-written implementations and proofs, and why Lema keeps its unverified host boundary small.
- Anatomy of a Lema program A plain-English tour of the five building blocks and two proofs inside a Lema program, from pure data and command vocabularies to Prog decision trees, Contracts, Impls, and host capabilities.
- Types and invariants How Lema types carry preconditions and invariants directly in function signatures, why proof fields erase to zero runtime cost, and why the data-type core stays intentionally small.
- Contracts, selections and proofs How Pythonic and Lean views present the same stored logic, how proof-optional contract selections let you ship code on day one, and how theorems compose across modules.
- Code stored by identity Why Lema stores declarations as content-addressed statements, templates, and proofs instead of source files, how syntax views work, and why AI coding agents move faster against a semantic store.
- Evolving programs, handles and concurrency How stateful Lema programs upgrade engines and contracts without breaking callers, enforce single-owner resource handles and in-flight ticket locks, and compose concurrent tasks, actors, and sessions.
- Capabilities and the host boundary How Lema structures external interaction across Layer -1, Layer 0, and Layer 1's six flat-byte OS capability families while keeping TLS, HTTP, S3, and crash recovery inside proved Lema code.
- The proved storage and HTTPS stack How Lema builds crash-safe block storage, RFC cryptography, X.509 validation, TLS 1.3, HTTP/1.1, and S3 inside the language above the six host capabilities, and the exact scope of each proof.
- The compiler and VM How Lema compiles accepted store objects directly to register bytecode with zero Lean or C compiler calls, executes them under bounded leases, and checks execution properties.
- How the store accepts code How Lema separates untrusted elaboration from source-free Lean kernel replay, enforces a fixed axiom floor, and keeps daily checking fast with incremental delta modules.
- Checked, tested and assumed Why Lema never uses a vague "verified" badge, how kernel receipts, contract selections, static IR guarantees, and releases stay distinct, and what stays with human engineers.
- Semantic version control Why Lema versions semantic declarations and evidence directly inside the store instead of text diffs, how the 7 change categories guide code review, and how multi-agent workspaces collaborate safely.
- Lema Cloud and LemaHub How the hosted service shares checked revisions between accounts, how LemaHub presents published projects, and which parts of the pilot are open today.
- Version and compatibility Lema v0.3 supports native Apple Silicon and Linux development, project starters, library packs, and local HTTPS applications on the VM.
- Where the ideas come from The languages, theorem provers, and computer science papers that shaped Lema, how Lema compares with Lean, Unison, and Bend 2, and the roots of the program core.
- Design decisions Architectural walkthrough of Lema's numbered design decisions (0001 through 0062), grouped by identity and content addressing, kernel checking and packs, authoring views and selections, and capabilities and VM execution.