Your Code Has Bugs. Lean4 Has Proofs: Formal Verification…
Talk by Varun Pant (AWS) on formal verification with Lean 4 for engineers, addressing why existing checks (model grading, tests, human review) cannot clear the volume of pull requests produced by coding agents. Presents a division of labor where humans own specifications and machines own code and proofs, explains Lean concepts via a chess analogy (tactics as moves, theorems as checkmate), and covers an AI rewriting zlib into Lean with 32,000 lines of proof checked by a small independent kernel. Also discusses Cedar, where authorization semantics are written in Lean while production code is Rust, reconciled via nightly differential testing.
# Channel Presentation Observations — Varun Pant, AWS
## 1. Explicit Self-Description (Creator Claims)
- **Speaker identity and role:** The speaker introduces himself directly:
> "Hi, I'm Varun Pant. I build AI products at AWS leading teams at in formal verification."
This is the only explicit self-description; it positions the creator as an AWS AI/formal-verification practitioner rather than a generic educator.
- **Institutional affiliation:** The title itself carries the affiliation: **"Varun Pant, AWS"**, reinforced by first-person institutional claims:
> "We at AWS have been working on an open-source tool called Strata."
## 2. Intended Audience
- **Software engineers and builders working with AI-generated code**, evidenced by the opening framing:
> "Coding agents are generating more code than ever. Builders are generating hundreds and thousands of PRs every week. How do you know that this is correct?"
The audience is assumed to be familiar with PRs, code review, and testing as current practices.
- **Practitioners rather than pure theorists:** Terms like "requires and ensures," Rust, C, and "differential random testing" are used with brief but not exhaustive explanation — a talk pitched at working engineers:
> "if folks are familiar with adding annotations, it's kind of similar to that"
## 3. Claimed Scope of Content
- **Topic scope:** Formal verification, centered on the Lean proof assistant, presented as the solution to correctness of AI-assisted code:
> "Formal verification can [say for all inputs the code is correct]."
- **Coverage demonstrated in the talk:**
- Spec-driven development workflow (with **Kiro** as an example)
- Lean fundamentals (kernel, tactics, theorem proving)
- Case studies: **zlib ported to Lean by "Andreo AI"**, **Cedar** (AWS authorization policy language, spec in Lean / production in Rust), **Verus** with Z3, **Eneus**
- **Strata**, an AWS open-source work-in-progress tool for verifying "any programming language"
## 4. Observable Presentation Patterns (Demonstrated, Not Claimed)
- **Tutorial/conference-talk format:** Motivating problem → concept explanation → analogy → worked examples → call to action ("You can get started with this today").
- **Pedagogical analogy:** The chess analogy for Lean tactics:
> "your goal is to checkmate the opponent... you have a bunch of tactics which are your moves."
- **Open-source emphasis:** Repeatedly highlights open-source tooling (Lean kernel, Verus, Eneus, Strata, Cedar, the zlib port) and multiple independent kernels.
- **Emphasis on human ownership of specifications:**
> "humans own the specification and machines own the code and proof."
- **Quantitative claims used as evidence:** e.g., "32,000 lines of proof," "about 100 million differential random tests run nightly. No version ships until this is satisfied."
## 5. Channel-Level Claims vs. Demonstrated Content — Summary
| Dimension | Evidence |
|---|---|
| Who is speaking | Explicit: "Varun Pant... AWS" (title + transcript) |
| Audience | Inferred from framing: engineers facing AI-generated code volume |
| Scope | Formal verification with Lean and related tools; explicitly scoped to verification, not general programming |
| Stance | Advocates formal verification over tests/LLM judges/human review for guaranteed correctness |
*Note: This is a single talk; no channel-wide metadata (subscriber counts, channel description, upload patterns) was supplied beyond title and transcript.*
# Delivery Observations: Varun Pant — "Your Code Has Bugs. Lean4 Has Proofs"
## Tone
- **Conversational, demo-lecture style** — informative but informal, marked by frequent interjections like "So," "Now," and "Well,": "So, here's an example of a Lean file…", "Well, one way is back driven development", "Well, you can write the functional specification of it".
- **Direct audience address**: rhetorical questions structure the talk — "How do you know that this is correct?", "How do you use this?", "What if you have code in Rust?".
## Recurring Phrases & Verbal Habits
- **"And this is important" / "this is really important" / "this is key"** — repeated emphasis marker:
> "Now, this is really important. You then validate the specification."
> "This is key."
> "Remember, this is important. Checking the specification is key."
- **"Remember…"** — used to call back earlier concepts (appears at least three times):
> "the kernel, remember the small trusted kernel?"
> "Remember the chess moves that we were making?"
> "remember the chessboard"
- **"So" as a sentence opener** throughout the talk, transitioning between points.
- **"very" as an intensifier**: "very extensible", "very powerful one", "very powerful calculator", "very important".
## Teaching Habits & Structure
- **Analogy-driven explanation**: the central **chess analogy** ("goal is to checkmate the opponent… tactics which are your moves") is introduced and then explicitly reused for later concepts — solvers contrasted against it ("A solver is a calculator, a very powerful one") and Lean repeatedly nicknamed "the chessboard".
- **Problem → solution framing**: opens with a list of failing alternatives ("LM as a judge… Tests? … Human code review doesn't scale") before introducing formal verification.
- **Example-laddering**: builds through a sequence of increasingly general cases — Lean-only (zlib/AandreO), Rust + Lean spec (Cedar), Rust + solvers (Verus), then any language (Strata). Each introduced with "Let's take another example" / "So, let's look at some examples".
- **Callback structure**: later points reference earlier ones ("kind of going back to our specification methodology that we mentioned").
- **Concrete numbers for credibility**: "32,000 lines of proof", "about 100 million differential random tests run nightly".
## Vocabulary
- Technical terms are **defined in plain language when introduced**: "tactics which do the work", "a solver is a calculator", pre/post conditions explained as "What must be true before and what must be true after".
- Consistent triad of **specification / implementation / proof**, with the phrase "what correct means" repeated for specification.
## Notable Isolated Moments (not stable patterns)
- **Closing wordplay**: "software and systems that are not probably correct, but probably correct" — the transcript appears garbled here (likely "not *probably* correct, but *provably* correct"), so the intended pun is uncertain from the transcript alone.
- **Self-correction mid-sentence**: "an incor- incorrect proof is rejected immediately" — a one-off stumble, not a pattern.
- Minor disfluencies ("That's uh a link", "uh run nightly") appear occasionally, suggesting unscripted delivery, though the sample is too short to confirm a pattern.
## Uncertainty Notes
- Timing/pacing and vocal delivery (pace, pauses, emphasis via voice) are not observable from the transcript alone; observations here rest solely on word choice and structure.
# Position Record: "Your Code Has Bugs. Lean4 Has Proofs: Formal Verification for Engineers"
**Speaker:** Varun Pant (self-identified: builds AI products at AWS, leading teams in formal verification)
## Motivating Claim: Existing Verification Methods Are Insufficient
Pant argues that AI coding agents generate enormous volumes of code ("hundreds and thousands of PRs every week"), and current correctness methods fall short:
- **LLM-as-judge:** "that's probabilistic"
- **Tests:** "they only check some inputs, not all"
- **Human code review:** "doesn't scale to match agent speed"
His stated conclusion: only formal verification "can say for all inputs the code is correct."
## Core Position: Formal Verification via Specification
- Formal verification provides **mathematical proof** that code satisfies a **specification** — what "correct" means — for **every possible input**.
- Advocates **spec-driven development** (e.g., with Kiro):
1. Write the specification (formally in Lean, or in natural language with AI auto-formalization).
2. **Validate the specification** — via human review or testing on some inputs. Pant stresses this repeatedly: "the specification is upstream... Everything else is downstream from this."
3. AI agent implements from the spec; verification tool proves implementation matches it.
- Division of labor: **"humans own the specification and machines own the code and proof."**
## Claims About Lean
- Lean is both a programming language and proof assistant; **same language for definitions and proofs** — no translation layer.
- Self-hosted ("implemented in Lean"), hence extensible.
- **Small trusted kernel** that checks proofs; proofs exportable and independently checkable.
- Chess analogy: tactics are moves toward checkmate (the theorem); interactive tree traversal with backtracking; the kernel "catches the mistake" (incorrect proofs rejected immediately).
- Multiple independent kernels exist (C++, Rust, Lean); open source; anyone can write one.
## Examples Presented
### 1. zlib → Lean (Andrej Karpathy-adjacent work attributed to "Andreo AI" in transcript; open source)
- C compression library converted to Lean "over a week or so."
- Natural-language spec → AI-generated formal spec → AI-written Lean code → helper lemmas → final theorem, checked by the kernel.
- Scale: **"32,000 lines of proof."**
### 2. Cedar (AWS)
- Open-source authorization policy language used by AWS Verified Permissions.
- **Specification in Lean, production code in Rust.**
- Example property: any satisfied *forbid* policy always results in denial.
- **~100 million differential random tests run nightly**; "No version ships until this is satisfied."
### 3. Rust deductive verification
- **Verus** (open source): uses the Z3 solver — described as "a calculator, a very powerful one" returning satisfiable/unsatisfiable. Pre/post conditions via `requires`/`ensures`; static, enforced by verifier, "erased at runtime... almost like ghost code."
- **Eneus** (as named in transcript): uses Rust MIR, functional translation to Lean, then the same theorem prover.
### 4. Strata (AWS, open source, **work in progress**)
- Goal: any programming language via user-created "dialects" — like a compiler lowering a high-level IR to **Strata core** (written in Lean), dispatchable to Lean proofs, SMT solvers, or model checkers.
## Closing Position and Qualifications
- Advice: start with Lean in the browser; pick the most critical code; write the spec; let agents implement and tools prove.
- Closing framing: software should be "**not probably correct, but probably correct**" — note: as transcribed this is contradictory/redundant; the intended contrast appears to be "probably correct" vs. "provably correct," but the transcript does not say this explicitly.
- Qualifications preserved: Strata is explicitly labeled **work in progress**; the zlib conversion timeline is hedged ("granted this happened over a week or so"); spec validation is stressed as essential rather than assumed automatic.
# Speaker Attribution & Provenance Record
## Video
- **Title:** Your Code Has Bugs. Lean4 Has Proofs: Formal Verification for Engineers — Varun Pant, AWS
- **Video ID:** `01a15ca7-9bac-771c-b6c5-0c665161ad74`
## Speakers
| Speaker | Role | Evidence |
|---|---|---|
| **Varun Pant** | **Creator / sole presenter** | Self-introduction: "Hi, I'm Varun Pant. I build AI products at AWS leading teams at in formal verification." He delivers the entire talk; no other speakers appear. |
- No guests, narrators, or additional identified speakers are present.
- Transcript opens and closes with `>>` markers and a `[music]` cue, indicating channel formatting rather than a distinct speaker.
## Referenced Sources & Third-Party Claims
- **zlib → Lean conversion:** "AI converted zlib, which is a C compression library, to Lean" — attributed to **Andreo AI** (described as open source; occurred "over a week or so"). The resulting proof reportedly had **32,000 lines**.
- **Cedar:** Open-source authorization policy language used by **AWS Verified Permissions and Access**; specification written in Lean, production code in Rust; reportedly **~100 million differential random tests run nightly**.
- **Verus:** Open-source deductive-verification tool for Rust using the **Z3** solver.
- **Eneus:** Uses Rust mid-level intermediate representation with functional translation to Lean.
- **Strata:** AWS open-source work-in-progress tool for multi-language verification via Lean.
- **Kiro:** Referenced in the context of spec-driven development ("back driven development, for example, with Kiro").
- **Lean:** Open-source programming language and proof assistant with a small trusted kernel; multiple independent kernels exist (C++, Rust, Lean); link mentioned to "Arena Lang" for adding kernels.
- **Lean in the browser:** Referenced as a getting-started resource via a pasted link (link itself not present in transcript).
## Promotional Segments
- The talk promotes **AWS-associated tooling and workflow** (Kiro, Strata, Cedar as used by AWS Verified Permissions), consistent with the speaker's AWS affiliation. No explicit commercial calls-to-action, sponsorships, or ads were identified.
## Availability & Limits
- **Comment availability:** Not stated in transcript or metadata.
- **Curated metadata:** None supplied beyond the video title; speaker identity is established solely via in-transcript self-introduction.
- Referenced links (Lean in browser, Arena Lang) are mentioned but not included in the transcript.
- The speaker's transcript closing line ("not probably correct, but probably correct") appears to be a transcription artifact; intended wording is not confirmed.
\>\> Coding agents are generating more code than ever. Builders are generating hundreds and thousands of PRs every week. How do you know that this is correct?
Using LM as a judge for the code? Well, that's probabilistic. Tests? They only check some inputs, not all. Human code review doesn't scale to match agent speed. None of these can say for all inputs the code is correct. Formal verification can. Hi, I'm Varun Pant. I build AI products at AWS leading teams at in formal verification. Formal verification provides mathematical proof that code is correct. For all inputs. You write what correct means, which is the specification, and a formal verification tool proves that your code satisfies it. If the proof passes, it holds for every
possible input. How do you use this? Well, one way is back driven development, for example, with Kiro.
You write what the specification is, which is what correct means. Either you write it formally, for example, directly in Lean, or you write it in natural language, and you let the AI auto formalize it. Now, this is really important. You then validate the specification. So, either the human reviews it, or you test that it holds on some inputs. And this is important because the specification is upstream. It's a living, breathing artifact that the builder interacts with. You want this to be correct. Everything else is downstream from this. The AI coding agent then goes and implements from the specification. And the formal verification tool proves that the implementation matches the specification.
So, humans own the specification and machines own the code and proof. Lean is a programming language and a proof assistant. It is the same language for the
definitions and proofs. There's no translation layer. It is implemented in Lean, which means it's very extensible. And this is important. It has a small trusted kernel. Proofs can be exported and independently checked. So, here's an example of a Lean file which has both the code and proof in the same language. At the top, you'll see the code, which is a function that reverses a list in Lean. So, reverse of one, two, and three gives three, two, and one. And right in the middle, you'll see a theorem. This is the proof. And this theorem prover approves a property which says that reverse of A plus B is in fact reverse of B plus reverse of A. And this holds for every possible input. How do you do this? You have something called as tactics which do the work, which we'll get to in a second. And the kernel, remember the small trusted
kernel? That checks the work. A good analogy to understand the Lean proof assistant is that of chess. So, in chess, your goal is to checkmate the
opponent. And you make a bunch of moves. You move the knight, you move the bishop. Similarly, in Lean, you have a bunch of tactics which are your moves. And it's the same chess board. It's interactive. You want to prove the goal, the theorem, checkmate. And you're kind of going down a tree. So, you're traversing the tree, you're trying different tactics. Maybe for some goals, you're not able to prove it, so you backtrack and then you try another a branch of the tree. Very similar to chess. And finally, you get a goal that hopefully proves the theorem, and then that small independent kernel confirms and checks it. The kernel catches the mistake. So, here's an example at the top where an
incor- incorrect proof is rejected immediately. And you only need to trust the small kernel. The good thing is that you can have multiple independent kernels. You yourself can actually go write one. It's
completely open source. You have kernels in C++, Rust, Lean. That's uh a link to the Arena Lang where you can go and add a kernel. So, let's look at some examples where you can put this to practice. The first one is having the specification and code both being in Lean. Now, this is open source Andreo. AI converted zlib, which is a C compression library, to Lean. Now, granted this happened over a week or so.
But, kind of going back to our specification methodology that we mentioned where you had specification at the top and then verification for the code, we'll kind of see the same thing
here. So, the natural language specification says that you decompress the output of compress returning the original data. And then, you have an AI that generates the formal spec. Now, remember this is important. Checking the specification is key. After you do that, the AI goes and writes your code in Lean, and then generates these helper lemma subgoals, and proves the theorem. And at the bottom, you can see that it's verified with that small independent kernel. So, what you just saw was that AI decomposed the problem into lemmas, which are subgoals. It proved each of them using tactics. Remember the chess moves that we were making? And it assembled it into a final theorem. Checkmate. And the kernel checked it. And this particular example had 32,000 lines of proof. So, it was pretty big. Let's take another example. What if you have code in Rust? Well, you can write the functional specification of it or the model in Lean. An example of that is Cedar. Cedar is an open-source authorization policy language, which is used by AWS verified permissions and access. The specification of Cedar is written in Lean. The production code runs in Rust. Why is this important? Because let's take an example. You have forbid Trump's permit. You want to make sure that for any forbid policy being satisfied, the request is always denied. This is key. Here you can see the example of what I was talking about, which is you have the Rust production code and you have the functional specification in Lean, and you run differential random testing to check that both of those for the same inputs give the same output. And there's about 100 million differential random tests uh run nightly.
No version ships until this is satisfied. Let's take another example. What if you have code in Rust and you want to deductively verify with Lean or solvers?
Before we go there, let's quickly talk about this new term solvers. So, remember we spoke of Lean being this chessboard interactive where you're making a bunch of moves trying to checkmate. A solver is a calculator, a very powerful one. You feed in a formula and it returns an output. In this case, satisfiable or unsatisfiable. So, an example of this is Verus, also an open-source tool. It uses this solver, this very powerful calculator, Z3. And if folks are familiar with adding
annotations, it's kind of similar to that where you can add specifications in the form of that. And the code is in line. So, you see these two requires and ensure keywords, that's what we call a
pre and post condition. What must be true before and what must be true after. And this is a static check. It's enforced by the verifier and erased at runtime. So, almost like ghost code. Another example of this is Eneus, which uses the mid-level intermediate representation for Rust and does a functional translation to Lean. And right after that, you use the same theorem prover, the same chessboard that we spoke of. Now, you may be asking, well, what if I have any programming language? We at AWS have been working on an open-source tool called Strata. This is work in progress, but the idea is that
you can have any programming language and you yourself can create what we call a dialect. Think of this like a compiler. You have a high-level intermediate representation and you lower it down to a low-level
intermediate representation, which is what Strata core is. Now, this is written in Lean. After you have all of these programs talking in the same language, which is the Strata core, you can dispatch it to any of the engines. For example, the Lean proof, remember the chessboard, or the very powerful calculator, SMT solvers, or model checkers. So, you can get started with this today. You can go to Lean in in your browser with the link I pasted, and you can pick your most critical code, write what correct means, which is the specification, which is very important, and then you can let your coding agent implement it and your formal verification tool prove it. So, hopefully in this brave new world, we have software and systems that are not probably correct, but probably correct. Thank you. \>\> \[music\]
