Fernanda Graciolli (@heyyfernanda) header
Fernanda Graciolli (@heyyfernanda) profile picture

AI + Verification. Founder @midspiral_ai. I build tools, like LemmaScript, that make sure your AI-generated code doesn't break the Internet.

Cambridge, MA
Joined June 2012
Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)Photo by Fernanda Graciolli (@heyyfernanda)
LemmaScript is escaping containment a little and i figured i should properly introduce it. so, a thread on what it is, what it is for, where it shines, and what its limitations are. TL;DR: LemmaScript is typescript w/ syntax for contracts. It's built for agents. You (or your agent) write a contract for a function as a comment annotation above it and a theorem prover checks the guarantee holds for every possible input. or it refuses and tells you which postcondition is violated. 👇 the comment annotations (the spec) look like this: one plain english sentence that states your intent: //@ contract A discount can never push a price below zero or above what it was. then a pre-condition states what must be true about the input in order for the result to hold: //@ requires price >= 0 //@ requires percent >= 0 && percent <= 100 then a post-condition states the result holds for every input that satisfies `requires`: //@ ensures \result >= 0 && \result <= price the function body underneath is the same typescript you already write. nothing changes at runtime, because the comments are stripped like any other comment. under the hood, `lsc check` compiles the function and its contract into a formal verification language called Dafny and runs a prover on it. the verifier gives your agent specific feedback allowing it to iterate until the proofs pass. there are tools that check whether the proofs are strong enough and match the initial intent (see claimcheck). it works best when you start a repo or a feature with LemmaScript because your agent will structure the codebase in a way that maximizes the verifier potential -- borrowing patterns from functional programming. this is early, of course, and there are limits. 1) the proof is only as good as the spec; 2) since translating TS to Dafny is tricky, there are known soundness bugs (like number semantics), but the modeling is still super useful for the agent when it comes to reasoning about TS code; 3) we still only support a subset of TS features (though we are working to expand!) all caveats aside, it WORKS. if you are tolerant to some rough edges, no matter how you use it, you will get better code and fewer bugs out of the box in your TypeScript projects. if you want to try it: `npm i -g lemmascript` or fork and send us PRs! we're not puritans. let your agent open PRs.
4
1
4
213
Fernanda Graciolli retweeted
Amazing Freudian slip
Exciting news: we're looking for interns for our formal methods team! Help us turn OCaml into the best language on the planet for writing probably correct code. Hiring in both London and New York. janestreet.com/join-jane-str… janestreet.com/join-jane-str…
1
5
296
37,725
Fernanda Graciolli retweeted
Exciting news: we're looking for interns for our formal methods team! Help us turn OCaml into the best language on the planet for writing probably correct code. Hiring in both London and New York. janestreet.com/join-jane-str… janestreet.com/join-jane-str…
21
54
16
927
105,633
model drops are always fun, but i seem to have settled down with Opus 5.5. last time i felt this way about a model was Opus 4.6. i guess i have a type.
42
I have whiplash from the formal verification discourse. One dude “verifies code in lean”. Everyone claps. Someone else says there’s a faithfulness issue when you verify in a language other than source. (Duh!) Everyone claps. It’s just tools. It’s all just tools and techniques.
50
this has been a lot of fun.
Hey look at that. LemmaScript is the most downloaded NPM package for both keywords: formal verification and formal methods. Fun times.
2
81
Rewind me 6 months and tell me LemmaScript will be used to formalize and uncover bugs in XState. I would have believed you, actually. There's a reason we built it, iterated relentlessly, and stuck with it through a dead zone. Be like Robert. Go formalize stuff.
Replying to @robertpenner
Now I'm tackling something more ambitious: formalizing XState's runtime behavior with LemmaScript. I started with XState's lightweight FSM, proving 31 laws governing state transitions, context updates and sequences of events. Comparing the formally verified model against XState's implementation helped uncover two bugs, both since fixed upstream. That led me deeper into XState's runtime. In my first week, I filed 7 bug reports involving subtle problems with transitions, event ordering and state behavior. It's exciting to see formal verification help uncover bugs in a mature, widely used open-source library.
1
1
5
477
Verification is not a single thing you do to code after it's written. Verification is flexible process / stack you can customize to fit your particular needs.
1
69
Fernanda Graciolli retweeted
The state machine renaissance There's a renaissance happening for state machines in software development. A prompt circulating on X this week tells coding agents to find all the implicit state machines lurking in a codebase. It's like a magic spell that brings submerged structures to the surface. Suddenly, scattered booleans, conditional branches, and ad hoc state transitions are revealed as parts of state machines. Once you've identified them, you can model them explicitly, constrain their transitions and eliminate entire classes of bugs. For JavaScript and web development, XState is an excellent tool for wrangling your state into a disciplined and diagrammable structure.
11
6
1
111
11,130
we need to start distinguishing between formal verification and lightweight formal verification (LWFV?) -- program verification sits on a spectrum. lot of people talking past each other bc the term formal verification is being used too loosely.
1
36
Fernanda Graciolli retweeted
The bull case for formal verification is "Here is a reusable library of properties/specs you can import in your code" not "Here is a few million LOC of Lean for you to go over, but the model passes!"
32
22
11
305
26,079
Hear me out… Software engineering
c̵o̵n̵t̵e̵x̵t̵ ̵e̵n̵g̵i̵n̵e̵e̵r̵i̵n̵g̵ ̵h̵a̵r̵n̵e̵s̵s̵ ̵e̵n̵g̵i̵n̵e̵e̵r̵i̵n̵g̵ goal engineering
1
2
147
every time i give a talk, i have to define “spec” first. a formal methods person hears a precise mathematical statement, a vibe coder hears a markdown list of requirements, and a pm hears a prd. we’re in the ad-lib era of ai definitions.
1
44
Fernanda Graciolli retweeted
Deciding how to help non-expert humans engage with formal verification specifications seems like one of the more important non-verifiable UX problems facing the rise of formal verification. 🧵
27
34
9
364
49,647
our company is @midspiral_ai btw. my co-founder is nada amin - an absolute beast in formal verification and programming languages.
35
Fernanda Graciolli retweeted
TLA+ has been incredibly useful, even on brownfield project, for turning implicit state machines into explicit specs where the entire flow can be tested and verified. There is a deep relationship between user journey, UX flow and formal specification that has an enormous amount of value to slop code. I wanted something more programmer-y and Typescript-y, and I came across Quint. It's highly agent friendly and seems to be maximally useful for this new paradigm of programming. github.com/quint-co/quint Quint is high level, like TLA+, and doesn't formalize Typescript functionality. So underneath that, lower level, is Lemmascript. lemmascript.org/ This lets you markup your Typescript with contracts. The combination of these two things makes Typescript feel more like a compile time checked language, more verifiable, stronger guarantees, and it finds different kinds of bugs than AI generated unit tests seem to. It's not a magic bullet but damn it does seem to improve code quality a lot. And the agents can rapidly iterate against it. I think we're gonna see a lot more of this kind of thing popping up, especially in interpreted languages like TS and Python. I'd recommend using Quint when you're just modeling your application and flows (although I've been installing it into an existing project with good results) and then telling your agent to add Lemmascript in the build phase.
38
46
7
569
42,455
I think it depends on the role. If I want a generalist builder, you gotta show you're a builder at heart. Builders build. If I want an implementer, side projects don't matter. I just want someone who is meticulous and consistent within a 9-5 window. Everyone has a strength.
From a startup founder: “it’s now a red flag for me if I don’t see side projects on someone’s resume / application, because it signals lack of autonomy. Because it’s now so trivial to build anything on the side, vs before.”
58
i have trust issues. so i'm on a rampage to make agentic workflows more deterministic one hook and contract at a time.
1
1
69
i accidentally just used "open sauce" instead of "open source" and i think i might stick with it.
1
69