Lean 4Coding AgentsProduct

Run Lean 4 and mathlib in the Cloud, in VS Code, in Minutes

August 9, 2026 · Oyren AI Team

Run Lean 4 and mathlib in the Cloud, in VS Code, in Minutes

Run Lean 4 and mathlib in the Cloud, in VS Code, in Minutes

Formalizing mathematics is addictive. Setting up the machine that checks it is not. Ask anyone who has tried to run Lean 4 with mathlib: the proofs are the fun part, and everything before the first is a tax. This post is about paying that tax once, for everyone — a way to run Lean 4 online, in a real VS Code, with mathlib already there.

The setup wall

A working local Lean 4 environment is famously front-loaded. You install elan, the toolchain manager, and let it pin the exact Lean version your project wants. You create a project with lake, Lean's build system, and add mathlib — the community's million-line mathematics library — as a dependency. Then you run lake exe cache get to download the prebuilt .olean files, a multi-gigabyte cache that exists because building mathlib from source takes hours. Then the VS Code extension, then the language server warm-up. None of it is broken; all of it stands between you and your first theorem.

The official web playground (live.lean-lang.org) fixes the first afternoon but not the second week: it is a shared scratchpad, one file at a time, with nothing persisted. It is exactly right for trying a tactic and exactly wrong for a project. What you want is a Lean 4 online editor with mathlib and your own files — without installing anything.

Lean 4 with mathlib, local install steps versus opening one cloud Power App in Oyren

A real Lean 4 instance, yours alone

Lean 4 is one of the Power Apps in an Oyren workspace — the same workspace that holds your notes, PDFs and repos. In the site's own words: a real Lean 4 instance running in VS Code, yours alone, with mathlib and the proof state beside the code. Not a shared playground, not a REPL behind a chat box — VS Code in the browser, on a machine provisioned for you, with the Lean extension and the mathlib cache already in place.

Here is the proof from Oyren's own demo — a pricing lemma, because formal methods are not only for textbooks:

theorem uplift_le_cap (h : u ≤ cap) :
    applyUplift u ≤ applyCap cap := by
  unfold applyUplift applyCap
  exact mul_le_mul_of_nonneg_left h base.le

The Lean infoview sits in the pane beside it. While the proof is open it shows the goal — ⊢ applyUplift u ≤ applyCap cap — with the hypotheses above it, and when the last tactic lands it flips to No goals and goals accomplished 🎉. The footer under the demo reads Lean 4 · mathlib · elaborated in 240ms: the feedback loop is the one you would tune a local machine for, without owning the machine.

A Lean 4 online editor with mathlib: VS Code in the browser showing Renewal.lean beside the Lean infoview reporting No goals

Put a coding agent on the proof

Here is where a cloud instance beats a laptop outright. The same Oyren workspace runs coding agents — Claude Code, opencode and others — in disposable cloud sandboxes with a repo checked out. Point one at your Lean project and the loop gets interesting: the agent proposes a tactic or restructures a lemma, the Lean server elaborates it, and the infoview's goal state is the ground truth that says whether the suggestion survived. AI theorem proving in Lean 4 works best exactly this way — the model drafts, the kernel judges.

Agents in Oyren commit as they go and open a draft PR for you to review, the same workflow this blog has used to write its own posts. And because the sandbox and your Lean instance live in the same workspace, "let the agent try the refactor while I keep the infoview open" is one screen, not two machines.

Who this is for

Students meeting theorem proving for the first time, who should spend their first hour on rfl and simp rather than on toolchain pinning. Researchers formalizing a result on whatever laptop the conference lent them. Engineers who want to prove a property of real business logic — the demo lemma above is literally a cap on a price uplift — without asking their team to adopt a toolchain. And the community's favourite on-ramp: solving Project Euler problems in Lean 4, where a ten-line puzzle about primes becomes a satisfying hunt through mathlib's number-theory lemmas. An instant instance with mathlib preinstalled is exactly what you want between seeing the problem and stating the theorem — nobody should sit through an afternoon of setup to formalize a puzzle. In every case the pitch is the same: use Lean 4 without installing Lean 4.

Honest limits

  • It is your instance, not your dotfiles. A fresh cloud VS Code will not have your local keybindings, your favourite fork of an extension, or your shell aliases until you bring them.
  • The cache covers mathlib, not your divergence from it. Depend on mathlib at a version the cache knows and elaboration is fast; pin something exotic and you will wait for a real build, cloud or not.
  • Agents draft, they do not understand for you. A tactic that closes the goal can still be the wrong lemma to prove. The infoview keeps everyone honest — including the model.

Start proving

Open a workspace, open the Lean 4 Power App, and state your first theorem — elan, lake and the cache are someone else's problem now. Get started at oyren.ai/workspaces.

The proof, the infoview strings and the 240ms elaboration figure in this post are taken directly from Oyren's live Lean 4 demo. Diagrams are hand-built SVGs.