DSS

DSS 2026 / Day 1 / Amber Hall

Formal Verification in the Age of AI: New Powers, New Traps

Petar Calic

15:05 · Recording

Watch on YouTube ↗Open recording viewerOriginal programme entry
Download plain textDownload timestamped JSON

Source: YouTube automatic caption track · Exported 2026-11-16. Timestamps link to the source video. Cue end times were not supplied.

Transcript

0:01My name is Peter,

0:02and I'm the lead protocol engineer at

0:05Spectra, which is a yield derivative.

0:07Okay.

0:08Today, I'm here to talk to you about how

0:12we are changing our development

0:13processes in this age of AI,

0:16and especially in critical software.

0:18And I will do this through the

0:20talk about formal verification.

0:25So this will not be a course about

0:26formal verification, although there are

0:28a few things I would like you to retain

0:30from this talk.

0:32First is a practical understanding on

0:34how to use formal verification

0:37in the use case of smart contracts.

0:40Secondly, because my experiment involved

0:43an enchanting setup, I know a lot of

0:45people are recently interested in that,

0:46so you can check it out.

0:49And

0:51lastly, the and most importantly, the

0:53answer to our question today is what are

0:55the limits of using AI for formal

0:57verification.

1:00So recently, formal verification made

1:02quite a lot of buzz, and some quite

1:04influential people started mentioning it

1:07really frequently, like Vitalik Buterin.

1:10But

1:11it seems that a lot of people have

1:13understood formal verification as some

1:14sort of

1:16a solution to vibe coding, some sort of

1:18magic tool that

1:21that makes your code that was untrusted

1:23suddenly trusted.

1:25Which brought me to think about the two

1:27questions I've written here,

1:29which is

1:30how do we adapt our processes to build

1:32safer software today in the age of AI?

1:34And if AI writes the code, can formal

1:37verification give enough confidence?

1:42For my experiment, I picked a few cases,

1:45and today I will present the one that I

1:47think is the most interesting one, and

1:49it involves the inflation attack.

1:51And

1:52the trick I used to kind of obfuscate

1:55the defining because it's such a popular

1:57attack, I'm sure that

1:59the agents it already in their data

2:02sets.

2:03So what I used to a bit trick them is

2:06that I solved it kind of partially. We

2:08use the virtual shares,

2:11which makes the attack non-profitable

2:12for a single victim,

2:15but

2:16without putting any decimal offset,

2:19the attack the attacker can still profit

2:22if there are more depositors.

2:33Yeah.

2:34So a bit of terminology for formal

2:36verification.

2:37You have informal and you have formal

2:39specs. So what are informal specs? Those

2:41are

2:42in plain English defined properties and

2:44invariance about your code.

2:46And for example, for the inflation

2:48attack, one could state that a

2:50successful deposit gives shares worth at

2:53least what was paid minus a small

2:54tolerance.

2:55What does that mean in practice?

2:57In plain solidity, it would be that a

3:00deposit and a redeem in the same

3:02transaction should return more or less

3:05the same amount minus some roundings or

3:08some fees.

3:11And here below you have the formal

3:12claim, which is the same property just

3:15translated into a

3:16more formal statement. And this is what

3:19CVL, for example, looks like in the case

3:21of Certora, which

3:24I used here

3:26because it's the most widely used tool

3:28right now for formal verification on

3:30smart contracts, although there are many

3:31other

3:32and emerging like Verity. So I invite

3:35you to check them all out.

3:37And here is the pipeline for formal

3:39verification in short. So you write your

3:42code,

3:43you write the informal specs in English,

3:46and then you translate them to the

3:48formal specs, which is the CVL.

3:52Then you write some modeling and

3:53assumptions and you feed that to the

3:55solver, which will then return the

3:57outcome, which is either a green pass

3:59that the rules are verified or a counter

4:03example.

4:09So we must not forget that AI and LLMs

4:13are probabilistic algorithms and that

4:17never mind how

4:19good the results are and the smart it

4:22looks you still cannot predict the

4:24outcome and most importantly you cannot

4:26explain it. You cannot explain why an

4:29LLM did a mistake.

4:32So this invites us to reason about

4:37what steps

4:39you should overlook and we which could

4:41you trust more that it does. And here

4:43are a list of

4:45things that I believe LLMs do greatly

4:47regarding formal verification.

4:50So

4:51I use it a lot to understand even my own

4:53system to brainstorm more invariance and

4:57properties. And

4:59the second thing

5:01about writing informal specification I

5:03don't let it write completely

5:06informal properties but

5:08I use it a lot to brainstorm new ones.

5:11And the third point

5:14a really useful trick

5:15is if you didn't already put on paper

5:18your properties

5:20you can check your own tests and you can

5:22ask the LLM to infer them because most

5:25commonly you already thought about the

5:27properties at least implicitly.

5:31Then

5:32what I believe the LLM is really good at

5:35it's to translate your properties into

5:37formal rules.

5:39Although this step also should be

5:40carefully reviewed because sometimes the

5:43the CML doesn't correspond really to the

5:45to the property you're intended.

5:48Then of course it's really good at doing

5:50all the boiler plate work and running

5:52your proofs and it can help you also

5:56understand the outcome. For example a

5:58counter example.

6:02Now we saw how LLMs can help you

6:05to to formal verification,

6:08but

6:10what are the its limits?

6:13So for my experiment I used a real

6:17production code just with a inserted

6:19vulnerability

6:21and

6:22the agent's task was really

6:24straightforward.

6:26It was to find bugs. It was to write

6:28first some properties

6:31informal specs and then to try to catch

6:33them using either testing or formal

6:36verification.

6:40So the

6:41test involved six completely independent

6:44agent runs

6:46with the same instruction, just a

6:47different [clears throat] starting point

6:49and a different tooling to resolve to.

6:52So for example

6:54the first group had no documentation at

6:57all. The agent was given only the pure

7:01raw code and its task was to infer

7:03informal

7:05specifications and to find bugs.

7:07The second batch had

7:10a simple README.

7:12It's the traditional README with the

7:14behavior defined of the code

7:17and some properties and the last group

7:19had

7:21the same README plus some deep

7:23handwritten

7:25explicit properties and invariance.

7:28And one group had to resort to foundry

7:31testing and one to CVL and we compared

7:34then how did they perform.

7:37So here is a summary of the workflow I

7:39used. It's not really relevant for the

7:41experiment, but I know people are

7:43interested in. So if you want to you can

7:45check it out on my GitHub.

7:48The important thing to remember is that

7:50I made a setup so that the agent's

7:54context is completely isolated. They

7:56were completely unaware of the

7:57experiment and the intended

8:01outputs.

8:02And the agent used was the Opus 5.5

8:06which is a frontier model.

8:09Now the two hypothesis I had that I

8:11expected was that AI will struggle to

8:14define the right security specifications

8:16on its own, but is really useful at

8:19translating from the informal specs to

8:21the formal ones.

8:22Also that formal verification gives a

8:24different coverage compared to testing

8:26and fuzzing.

8:28But I missed a really important idea

8:30that turned out to be the most

8:32interesting finding of this experiment,

8:35and that's the interpretation of the

8:37output.

8:38In fact, none of the agents didn't state

8:42clearly that the that the attacker could

8:44be profitable.

8:46All of them recognized that there was an

8:48issue related to the donation mechanism,

8:51and

8:52they also proposed a patch

8:54which was effective enough, but none of

8:57them stated clearly that there was the

8:59attacker could be profitable, which

9:01gives the vulnerability a whole other

9:04severity level.

9:06It could be it could might as well be

9:08just a coincidence that the patch also

9:10covered the severe case.

9:14It only appeared after a few prompts to

9:17recheck and be certain that there is no

9:22real

9:23danger

9:25in that in that sense. Yeah, so another

9:28interesting

9:29thing we saw is that with better specs

9:32we received the better tests and better

9:34coverage. For example,

9:38just the readme, the agent stated the

9:40property that the shares should always

9:42be positive, which is nice, but it

9:44covers only the most extreme case where

9:46the

9:47shares round down to zero, which it can

9:51round down not completely to zero, but

9:52still occur some loss.

9:57Yeah, the better requirements improved

9:58the tests, but not the economic

10:00interpretation. Still, I didn't observe

10:03the agents

10:04say explicitly that this is a severe

10:07vulnerability where the attacker could

10:09profitable.

10:11So did formal verification in this case

10:14um

10:16cover and uncover more bugs? No. And in

10:20fact even we had we observed some

10:22weaknesses where the human intervention

10:25was necessary.

10:27Like we had some impossible states that

10:28were wrongly interpreted. We had some

10:32mistakes made during

10:34trying to make the proofs pass because

10:36if you use heavy mathematics like

10:39multiplication and division often the

10:41proofs can

10:43can time out and you need to resolve it

10:45to some techniques like to simplify the

10:47proofs, divide them or to

10:50[snorts]

10:50simplify the the models.

10:54Although

10:55and the really power of formal

10:58verification is that once the check

11:00returns green you're sure that under

11:02those assumptions the the cases are

11:05covered and the code is safe.

11:13So a bit more about the first

11:17issue

11:18that we had is that

11:20proof can return a counter example

11:22because really the property is violated

11:24but it can also be violated simply

11:26because the state it set up was not even

11:30not possible. For example here we had

11:33the the wrapper contain more assets than

11:36it had minted shares and of course then

11:38the ratio will round down to zero but it

11:41is not a possible state.

11:46During the

11:48the agent when he tried to make the

11:50proof pass also we observed he did some

11:52simplifications that removed the cases

11:56where the bug could be located.

12:00Yeah for example in the previous case it

12:03put assumption that the assets in the

12:06wrapper are equal the supply which made

12:08the the bug hidden.

12:13Now

12:14more importantly where did formal

12:16verification prove itself worth it?

12:18Is that it forced the agent to find a

12:21fix that really solved completely the

12:23bug.

12:24Because the in other cases the solution

12:28by the agent was to bring up the decimal

12:31offsets,

12:32which is an economic solution to the

12:35bug. It makes the attack very expensive,

12:38but in fact

12:40not completely solved. The prover still

12:42would complain.

12:44While the one the the agent that had to

12:48use formal verification, it found a fix

12:50that

12:51made it mathematically impossible this

12:53type of error by internally tracking the

12:57assets deposited.

12:59Which is a

13:00solution of a better quality.

13:05So what can we take out from here?

13:08How do we adapt today our development

13:10processes?

13:13So the old school way to in development

13:16was to do first specs, write down your

13:18properties, do the implementation, do

13:21some testing, then

13:23do more some cycles,

13:25fuzzing, integration tests, audits and

13:27optional formal verification if you have

13:29the budget and the resources because it

13:31was really difficult.

13:33But today the implementation cycle is

13:36really quick.

13:39So you should do more iterations and in

13:41my opinion spend a lot more time on the

13:43specs.

13:45And now formal verification in my

13:47opinion should be part of the testing

13:49pipeline because as you saw it's quite

13:51doable.

13:57Now the key takeaways from today is you

13:59should do a lot more specs. You should

14:01spend more time brainstorming the

14:03invariance, thinking about your designs,

14:07the economic guarantees.

14:09Then you should maintain your spec. Go

14:11through them again and again and edit if

14:13needed.

14:14And it should the cornerstone of your of

14:18your system. It should be the hardest

14:20thing to bend. AI often can adapt tests

14:24so they fit the implementation and your

14:26specs should be completely out of the

14:29equation.

14:31And the tools

14:33for more verification is a really

14:35powerful tool,

14:37but the main thing is to maintain your

14:39properties and invariants and

14:41that way even you can find interesting

14:44bugs using

14:45using

14:46standard

14:48and already very known techniques like

14:51fuzzing and unit tests.

14:53Although formal verification really does

14:56provide some

14:57really important properties when

15:00verifying your code.

15:03Thank you.

Source and accuracy details

Source export SHA256: 3f1bd4932fd8ae6b7c664dad86975bd9a6721b9a1fa1fb82daed18aae91601cb