Verified, not just tested

A browser engine you can prove things about lets you reason about your own web app as the browser will actually run and render it, not about a model of it.

Here's a real one: a counter page, its script, and a theorem about where its button ends up after any number of clicks (up to 226), in every viewport at least as large as the button, checked by Lean's kernel on every build.

The page examples/lean-engine/counter.html
<!doctype html>
<html><body style="margin:0"><button id="inc" style="display:flow-root;width:60px;height:30px;margin:0;padding:0;border:0;box-sizing:content-box">+1</button> <span id="out">0</span>
<script>let n = 0;
document.getElementById("inc").addEventListener("click", () => {
  n = n + 1;
  document.getElementById("out").textContent = "Count: " + n;
});
</script>
The theorem Proofs/LeanEngine/Counter.lean lines 44–64
/-- **The counter page from its source**: parse `counterHtml` (the file `examples/lean-engine/counter.html`), create a
Lean-engine session over the document, run the page's script and click the button (node 5) `k` times: `#out` (node 8)
reads `"Count: " ++ toString k`, and the button's box is at the origin, 60px × 30px, inside any viewport at least that
large. Assumed: the parses (`PageParses`, `StyleParses`, `ScriptParses`, each checked by `#guard` when its file builds)
and what the session's creation gives the engine (`EngineFresh`). -/
theorem counter_html (hpage : PageParses) (hstyle : StyleParses) (hscript : ScriptParses) (d : Document)
    (hd : Telescope.parsePage counterHtml = .ok d) (ls : LeanSession) (hls : LeanSession.create d = .ok ls) (wD : ObjId)
    (gb : Std.HashMap JSStr ES.Binding) (gtv : ES.Value) (fp : ObjId)
    (he : EngineFresh ls.es.eng ls.host ls.es.state wD gb gtv fp) (k : Nat) (hk0 : 0 < k) (hk : k < 2 ^ 26)
    (hfu : 22 + 3 * k ≤ ls.es.state.fuel) (env : MediaEnv) (state : DynState) (loader : Loader) (url : Option String)
    (vw vh : Au) :
    ∃ ls', clicks (ls.runScript counterScript).2 5 k = .ok ls' ∧
      OutText ls'.host.doc 8 ("Count: " ++ toString k) ∧
      ∃ box, buildBoxTree ls'.host.doc (computeStyles ls'.host.doc env #[] state loader url) env noImages
          (computeStylesAndPseudo ls'.host.doc env #[] state loader url).2 = some box ∧
        ∃ f, (layout box vw vh).at? [0, 0] = some f ∧ f.node? = some 5 ∧
          f.rect = ⟨⟨0⟩, ⟨0⟩, ⟨3600⟩, ⟨1800⟩⟩ ∧ (⟨3600⟩ ≤ vw → ⟨1800⟩ ≤ vh → f.rect.Within ⟨⟨0⟩, ⟨0⟩, vw, vh⟩) := by
  have hm : DocMatches d := by unfold PageParses at hpage; rw [hd] at hpage; exact hpage
  have hdoc := create_doc d _ ls hls
  have fr := fresh_of_doc ls.es.eng ls.host ls.es.state wD gb gtv fp he (hdoc ▸ hm)
  exact counter_page ls 5 4 2 8 wD gb gtv fp fr hstyle hscript k hk0 hk hfu env state loader url vw vh
Telescope.parsePage counterHtml = .ok d
The page's HTML source, parsed by Telescope's HTML parser, gives the document d.
LeanSession.create d = .ok ls
A session over that document on leanjs, the ECMAScript interpreter written in Lean.
clicks (ls.runScript counterScript).2 5 k
Run the page's script, then click the button (node 5) k times, for any 1 ≤ k < 226 (with enough fuel for the interpreter).
OutText ls'.host.doc 8 ("Count: " ++ toString k)
Afterwards, #out (node 8) reads “Count: k”.
buildBoxTree … (computeStyles …)
The resulting document is styled by the cascade, with the user-agent style sheet, and turned into boxes…
(layout box vw vh).at? [0, 0] = some f
…and laid out in a viewport of any size vw × vh; f is the button's box.
f.rect = ⟨⟨0⟩, ⟨0⟩, ⟨3600⟩, ⟨1800⟩⟩
It is at the origin, 60 × 30 px: lengths are exact integers in 1/60 px, with no floating point anywhere.
f.rect.Within ⟨⟨0⟩, ⟨0⟩, vw, vh⟩
So it lies inside every viewport at least that large, for every media environment, interaction state, loader and URL.

What it assumes is stated, not hidden: the parses of the page, its style attributes and its script (each checked by #guard when the file builds, since the kernel cannot run the parsers), and EngineFresh, what creating the session gives the engine, not proved yet. Its axioms are Lean's standard three (propext, Classical.choice, Quot.sound); the proofs use no sorry and no native_decide. How it is put together.

Other theorems in Proofs/ are reusable pieces: that a block of fixed size with its own formatting context gets exactly that box whatever its contents; that a style attribute's declaration sets the computed value unless an !important declaration or another of the element's own rules overrides it; which box tree a document shape generates. Approach, gaps and lessons: docs/proofs.md.

Proofs about React apps

The goal is theorems about real web apps, so the proofs run React's own production code — not a model of it — on leanjs, an ECMAScript interpreter written in Lean, with Telescope's DOM, style and layout around it.

For a counter written with useState, a click's whole path through react-dom has been proved function by function, from the state setter to the queued microtask, through the render of each fiber, to the commit's update of the button's text, and composed into one theorem about the click's microtask. That work brought a program logic for the interpreter, frames that say what each function leaves alone, and a tactic that steps through JavaScript statement by statement.

In progress: discharging that theorem's premises from the page as it actually runs, so it becomes a page theorem like the counter's above; then a shadcn/ui switch. The plan and the log are in docs/react-proofs.md.