HomeVideos

Formal methods with Hillel Wayne

Now Playing

Formal methods with Hillel Wayne

Transcript

2601 segments

0:00

Let's talk about formal methods. There's

0:01

some sort of implicit mechanism in your

0:03

brain that can [music] see that and know

0:04

what the function is supposed to do. So

0:06

step one of what I do with formal

0:08

methods is asking can we take that

0:10

implicit knowledge and make it explicit?

0:12

Can we figure out what a function is

0:13

supposed to actually be doing and write

0:15

that down in a way that can be shown to

0:17

anybody?

0:18

>> Why are we not doing formal testing for

0:19

everything?

0:20

>> When you start talking about like most

0:22

interesting domain problems, you have to

0:23

pull in so much context that basically

0:26

even writing what the function is

0:27

supposed to do becomes a nightmare. the

0:29

imperative program you're right that

0:30

we'll get 99% of the time is probably

0:32

good enough to use in almost all cases.

0:34

>> One story I've heard and I think you

0:36

might have been involved is AWS using TA

0:39

plus.

0:39

>> They talked about how a couple of people

0:41

in the company were interested learned

0:42

TA plus and another language called Plus

0:44

Scout and applied it to aspects of the

0:46

Dynamo DB and S3 storage systems. In

0:48

doing so, they were able to find fairly

0:50

complicated bugs that [music] could

0:52

potentially lose data. we have AI

0:54

generating way more code maybe for more

0:56

verification or property based testing

0:58

could be more useful. [music] Do you

0:59

think this will happen?

1:01

>> I've been doing a lot of experience in

1:02

this myself and I think the one thing AI

1:05

is extremely bad at.

1:10

There's a popular theory going around

1:12

that AI will finally make formal

1:14

verification go mainstream because when

1:16

machines write the code, humans will

1:18

need mathematical proof that is correct.

1:20

Today I'm talking with one of the best

1:22

people to respond to this, Hill Wayne, a

1:24

formal methods consultant. He taught TLA

1:26

plus a popular formal specifications

1:29

language across the industry, wrote the

1:30

book logic for programmers and will soon

1:32

be joining antithesis. In today's

1:34

conversation, we discuss the crossover

1:36

project. Hill's research interviewing 15

1:39

plus traditional engineers to answer the

1:40

question, can software engineers also be

1:42

considered real engineers? How AWS used

1:45

TA plus? an overview of how Amazon found

1:48

a rare bug inside of Dynamo DB using

1:50

this formal specifications language, a

1:52

deep dive into property based testing

1:53

[music] and why this is a middle ground

1:55

that most engineers should probably

1:57

adopt and many more. If you want to

1:59

understand more about formal

2:00

verification and get a sense of whether

2:02

this approach could go mainstream with

2:04

AI, this episode is for you. In today's

2:07

episode, we'll get to the question, does

2:08

it make sense to use formal methods to

2:10

verify AI written code? As a spoiler,

2:13

the answer will be proper formal methods

2:15

are an overkill for this, but

2:17

lightweight formal methods can actually

2:18

be helpful. This is where I need to

2:20

mention our presenting sponsor and

2:23

antithesis verifies your systems

2:25

correctness by running your whole system

2:26

in hostile simulation and finding bugs.

2:29

It does this by using an approach called

2:30

deterministic simulation testing or DST

2:33

which AWS distinguished engineer Mark

2:35

Burker and Ankor Desai have described as

2:37

lightweight formal methods. Setting

2:39

aside in synthesis for a minute, if you

2:42

as an engineer want to get more serious

2:43

in verifying that your system works as

2:45

intended, your best bet would be to use

2:47

lightweight formal methods. Now back to

2:50

antithesis. Antithesis is turbocharges

2:52

testing by running your whole system

2:53

under aggressive fault injection.

2:55

Imagine antithesis as hundreds or

2:57

thousands of versions of the Mario game

2:59

running. Each instance aggressively

3:01

trying to break the game with

3:02

increasingly weird input combinations.

3:04

With antithesis, you can specify

3:06

properties at the whole system level and

3:08

antithesis will actively try to disprove

3:10

them. So you can be confident that if

3:12

your system holds up in antithesis, it

3:14

will hold up in production. There's good

3:16

reason teams like Jane Street, Fly.io

3:18

and the CCD community rely on

3:19

antithesis. Head to

3:21

antithesis.com/pragmatic

3:22

to learn more. So hello, welcome to the

3:25

podcast. Thank you so much. I'm really

3:27

excited to be here.

3:28

>> It's so nice to have you here. I was

3:30

curious, you're very well known for for

3:32

meth methods, for programming, for for

3:34

logic, for all of these topics, but how

3:37

did you get into tech? So, to start, I

3:39

never really saw myself as a technical

3:41

person. I like computers growing up and

3:44

I did a tiny bit of programming. My

3:45

father was a programmer. He taught me

3:47

visual basic, but I always wanted to do

3:49

physics and math. That was like my

3:50

dream. I put in my college application,

3:52

I wanted to listen to the heartbeat of

3:53

the universe.

3:55

Don't ever take advice from like a high

3:57

schooler for writing. Just Just saying.

3:59

But after about 3 years of doing this in

4:01

college, I realized that I kind of like

4:03

the idea of physics, but I didn't enjoy

4:05

doing it and I couldn't see myself doing

4:06

it for 50 years. What part I did enjoy

4:09

though was the programming in the labs.

4:11

That was the most fun part to me. So I

4:13

thought, well, if this is what I enjoy,

4:15

why not try to do it full-time? So after

4:17

college, I left for San Francisco and

4:19

became a um developer, a Ruby on Rails

4:21

developer in education technology. After

4:23

some time, move back to Chicago. And

4:25

then in the course of the next job I was

4:26

working in also in education technology

4:28

I fell into my current niche which is

4:30

formal verification and formal methods.

4:32

>> The first time I came across your

4:34

writing because you you you write a blog

4:36

a pretty regular one and I I really

4:38

enjoy your writing. The first time was

4:39

with the crossover project. This was a

4:42

project where you attempted to answer

4:44

are we as software engineers actually

4:48

engineers?

4:48

>> Yes.

4:49

>> Can we talk about this project?

4:51

>> Absolutely. So I guess I should probably

4:53

start with the motivation

4:55

which was I've read a lot of books on

4:57

software and I've read a lot of online

4:59

articles about software and one of the

5:01

favorite things that software developers

5:03

do is argue about whether it should be

5:04

engineering or not right and there's the

5:07

camp of people that say well we don't

5:10

deserve to call ourselves engineers we

5:12

should not they are so far above us we

5:13

shouldn't even like consider ourselves

5:15

in the same space and then there are the

5:17

people who are like what we do is so

5:20

special and so unique Engineering

5:22

doesn't have anything on us. They can't

5:23

hold a candle to what we do. You see

5:25

books like software craftsmanship which

5:27

talk about how like oh engineering is

5:28

this really boring slow field and

5:31

software is this incredibly creative

5:33

special wonderful thing. I was very

5:35

permanently in camp one. I thought we

5:36

were not engineers. We didn't deserve to

5:37

call ourselves engineering anything like

5:39

that. What I do for work is really

5:41

carefully analyzing software systems and

5:42

I thought ah this is real engineering

5:44

and everything else is not engineering.

5:45

Then I found this talk by Glenn

5:47

Vanderberg where what he did was he read

5:48

a bunch of engineering books and

5:50

compared them compared them to what we

5:51

do in software. And he said actually

5:53

this looks really similar to what we do

5:55

in software. And I thought that can't be

5:57

right. I need something more rigorous.

5:59

I'm going to have to talk to people who

6:01

did both engineering and software

6:03

development and see what they say. And

6:05

they all agreed with him. So I was

6:07

wrong. We're engineers. Can can we go a

6:09

little bit into it?

6:10

>> So, as I started talking to the first

6:13

people, I realized that this was a much

6:14

deeper project than I ever expected. And

6:17

I decided I needed to have as

6:18

comprehensive a look at traditional

6:20

engineering as I could possibly get.

6:22

There are many kinds of engineering.

6:23

There's not just building bridges, but

6:25

there's designing circuits. There's

6:27

figuring out chemical processes. There's

6:30

industrial engineering, which is

6:31

figuring out the layouts of factories

6:33

and how we organize kinds of labor.

6:35

There's just so many different kinds.

6:37

And I wanted to see every single kind's

6:39

view into what engineering looked like

6:41

to compare them all to software which

6:43

when you think about it when we say like

6:45

oh software isn't like building a bridge

6:46

maybe it isn't but is it like designing

6:48

a circuit is like figuring out a

6:49

chemical flow maybe those are much more

6:51

closer to the kinds of engineering we do

6:53

I needed to know I think in the end I

6:55

talked to about 15 or 20 people in total

6:58

across about six or seven different

6:59

fields and what were the similarities

7:02

that you found that software engineering

7:04

has with either specific types of

7:06

engineering ing or across the the board.

7:09

>> If I had to summarize what I found in

7:11

general, I'd put it like this. Everybody

7:14

hates waterfall.

7:17

>> No way.

7:18

>> Core tension of engineering is between

7:22

how expensive it is to make a mistake

7:23

and how quickly you can iterate. The

7:25

faster you can iterate, the less

7:27

planning you need to do before you

7:29

iterate. And the more expensive it is,

7:31

the more planning you need to do. That's

7:33

why for example when you're building a

7:34

building where you can't like build it

7:37

multiple times and see what happens you

7:39

have to do a lot of planning up front

7:41

but even then you are looking for ways

7:43

to iterate on the plan you do things

7:45

like build scale models you software to

7:47

simulate the building you do like CAD

7:49

models etc and in other fields like in

7:52

for example electrical engineering you

7:53

have the ability to come up with a

7:55

design test it and then throw it to the

7:56

fab and get something back so they will

7:58

iterate a lot more than civil

7:59

engineering does

8:00

>> ah interesting enough I I heard The term

8:03

smoke test originated from electrical

8:05

engineering. Actually,

8:06

>> I did not look into that, but I could

8:08

believe it.

8:08

>> Yeah, apparently it's it's when you have

8:10

a a test circuit and you just hook it up

8:12

and if it does if it smokes, it's

8:14

already bad. That is very interesting.

8:16

So, even within engineering, when we say

8:18

traditional engineering, there's just

8:20

layers of engineering or differences,

8:21

right?

8:22

>> Layers of iteration. I'd say one of the

8:24

first people I talked to was actually a

8:25

mining engineer. He designed mines deep

8:27

underground to make sure that they were

8:29

stable and didn't like leak toxic

8:30

chemicals. And the first thing he

8:32

pointed out to me was that they had

8:33

their agile revolution in 1960. They

8:35

called it, I believe, the vianese

8:37

vianese tunneling method as a way of

8:39

really quickly iterating through

8:40

building a mine and tunneling through

8:42

rock. Basically making the change as

8:44

fast as they could, seeing how the rest

8:46

of the system reacted to it and then

8:47

course correcting based on that.

8:49

>> Okay. So I guess we we all hate

8:51

waterfall.

8:52

>> We all hate waterfall

8:53

>> or the idea of waterfall.

8:54

>> Yeah. What are some of the interesting

8:56

differences that you came across either

8:57

where engineering is ahead of us or

8:59

traditional engineering has you know

9:01

does have things on us which you were

9:02

hoping to find or places where actually

9:04

software engineering is ahead in some

9:06

ways.

9:07

>> There's both differences in how we

9:08

practice it but also differences in the

9:11

shape of our material because every

9:13

engineering concerns a different

9:14

material. They have different

9:16

constraints. While it's true that

9:17

everybody tries to iterate as fast as

9:19

they can often turning to software to do

9:21

that software is the best at it. The

9:23

best comparison is chemical engineering

9:25

where I talked to people saying that

9:26

they would set up their experiment, run

9:28

it overnight and get the results the

9:29

next day and that was fast. With us, we

9:32

can basically press F11 and get the

9:33

result, right? And that allows us to

9:36

basically iterate much faster than even

9:37

those fields can. I think we all kind of

9:40

know this. One thing that we might not

9:42

realize as software engineers is that

9:44

our work is a lot more consistent than

9:46

other fields. The example I always do

9:48

sometimes because I've given a talk

9:49

about this is I would pull out like a

9:52

CPU chip or like a stick of RAM and I'd

9:54

say like hey here's the spec sheet and

9:57

if you look at the spec sheet it says

9:59

this resistor has a resistance that is

10:01

within 20% of 100 ohms as long as you

10:04

keep it between 20 and 50° centigrade.

10:06

So they're basically saying that if they

10:08

make a thousand of these, there's going

10:09

to be a variance of 20% across all

10:11

10,000. And the only way to know is to

10:12

test them. And then if you run it for

10:14

too long or you heat it up too much,

10:17

it's going to change again. With

10:20

software, assuming no like CPU bugs or

10:22

anything like that, the same program if

10:24

it runs on this computer, it'll run on

10:26

your computer exact same. Sort this list

10:28

the exact same with the sorting

10:29

algorithm. Does this also mean that we

10:32

might not account for v variability as

10:34

much as other engineering disciplines

10:36

do?

10:37

>> I'd say so. The variation we have to

10:38

deal with is kind of our own making,

10:40

right? We're basically saying, okay,

10:42

we've got all these different systems,

10:43

all these different APIs versus other

10:45

people like we have all these different

10:46

chipsets. We've got all these different

10:47

like ports or sizes, but also if you

10:50

happen to touch like an iron screw to a

10:52

tungsten screw, they're going to cause

10:53

corrosion between the two of them. And

10:54

also, some of your screws are a little

10:56

bit too bigger than others and some are

10:57

a little bit smaller than others. are a

10:59

bit longer etc.

11:00

>> And how did you see the similarities or

11:03

differences of software engineers for

11:07

example often interact with customers

11:08

with end users who use the software in

11:11

other engineering fields is this also a

11:13

thing where as an engineer you will talk

11:15

or know your customer or just not

11:18

knowing them at all.

11:19

>> I think it depends because different

11:22

engines I talk to had different

11:23

experiences. Some said that they felt

11:25

that with software they felt much closer

11:27

to the customer with other ones they

11:29

said they felt much further. So I think

11:31

it's hard to really tell there.

11:32

>> One thing I remember vividly is a

11:35

difference that you pointed out which

11:36

was very different and almost makes

11:38

software engineering a bit higher status

11:41

or a better place is open source the

11:43

concept of open source.

11:44

>> Yes. So that is one thing that seems

11:48

very special about software versus any

11:51

other field. Like the reason I'm here in

11:54

Hungary right now with you is because

11:55

I'm going to be speaking at um craft

11:57

conference, right?

11:58

>> Yeah.

11:59

>> Most other fields of engineering or in

12:02

fact any other field of like human labor

12:04

has two kinds of conferences. Academic

12:07

conferences where they talk about

12:08

research and trade shows where they try

12:10

to sell where vendors try to sell to

12:11

like companies. Software is kind of

12:13

unique in having the third kind of the

12:15

practitioner conference where we are

12:17

just meeting to get better at what we

12:19

do. We also are really the only kind to

12:21

really focus heavily on like open source

12:23

and making our knowledge freely

12:25

available for any language. You can

12:26

probably find out how to learn a

12:27

language online, right? You don't have

12:28

to buy a book. You don't have to like

12:30

talk to the vendor to learn it. That's

12:31

something really special about software.

12:33

I wonder why this might be both the the

12:36

fact that we do share a lot of the

12:38

information or the craft or how we build

12:40

things. Even some of the largest

12:42

companies, they I think of like an Uber

12:44

or Airbnb, these are hundred billion

12:46

dollar companies. they will not

12:48

particularly hide how they built that

12:51

piece of software Uber publishes and

12:53

does talks about their app that is used

12:55

by all these people how exactly they

12:57

built it or approximately I wonder why

13:01

this became unique in software and in

13:04

not the rest of engineering what does

13:05

the rest of engineering have to lose

13:07

with it or or or what did we do to get

13:10

here

13:11

>> I'm going to switch to speculation for a

13:13

second this isn't something that I could

13:14

really speak on with full authority But

13:17

my guess is that part of it is cultural,

13:20

but another part of it is that the

13:22

material we work with is the same as our

13:24

product, right?

13:26

We are using software to write software

13:29

versus using tools and lathes to build

13:31

things or using software to design

13:34

circuits. And I personally think that

13:36

that similarity basically that we are

13:39

using the same materials on both ends is

13:40

what makes it so much easier for us to

13:42

talk about things like open source.

13:44

interesting how I I like this thinking

13:46

of of materials used in each engineering

13:49

and how our material is software itself.

13:53

Of course, it's hardware engineering and

13:54

and we know that's a bit different of

13:55

course, but already there's a divide

13:57

between hardware engineering and

13:58

software engineers and how they how much

14:00

they share, how much we know about them

14:02

and so on. I kind of wonder I've got

14:04

some friends who do like 3D printing and

14:06

it seems like and I haven't looked into

14:07

this but it seems like they also have

14:09

like a very open space of like sharing

14:11

things freely and I wonder if that's the

14:12

same because it is so easy to share and

14:14

because like the unit of value is the

14:17

schematic there if that kind of leads to

14:19

the same thing. I also wonder if hacker

14:21

culture might play a thing in places

14:23

where it's easy enough to afford to get

14:25

started on a thing for example ham

14:28

radios which is not engineering but

14:29

there's a thriving community where they

14:32

share the setup the things they they

14:34

talk with each other small electronics

14:37

might be and then but ultimately

14:39

software started in the what 70s when it

14:41

was affordable anyone could buy a

14:42

computer

14:44

maybe the internet I'm also just

14:45

speculating

14:46

>> yeah definitely something worth doing a

14:48

follow-up project on Right.

14:50

>> Well, you've already spent a bunch of

14:51

time on it.

14:52

>> Don't give me so many rabbit holes.

14:53

There's already too many rabbit holes in

14:54

my life.

14:55

>> One more thing that you brought up is

14:58

version control and the and the the the

15:00

fact that in software we just take it

15:02

for granted. We have version control

15:03

everywhere. And you said that this is

15:05

super unique across most of engineering.

15:07

>> Yeah. I interviewed like 20 people on

15:09

this. I think all 20 mentioned version

15:11

control as a thing they wish they had in

15:12

their old field.

15:13

>> Wow.

15:14

>> Yeah. Now to be clear, they do have

15:15

things like change management in like

15:17

other fields, but I think version

15:19

control as we have it is so much more

15:21

sophisticated than anything they have.

15:23

It's like comparing like a modern car to

15:25

a model T.

15:26

>> What do you think there are things that

15:29

now having talked with so many people

15:30

and learned about the different

15:32

engineering cultures like active

15:34

charging cultures? What could we learn

15:37

from them? What are some kind of

15:38

inspiration that might be useful here or

15:40

there? Yeah, this is a harder question

15:42

because while everybody I talked to

15:43

mentioned those two things of openness

15:45

and version control, I got a much more

15:47

scattering set of answers when talking

15:50

to people about what we could learn from

15:51

their old fields. The two things I kind

15:53

of gleaned out is that one, while we are

15:55

a lot better at iterating than other

15:58

fields, we're worse at the planning

16:00

part. Like we still need to do some kind

16:01

of planning before we iterate and we

16:03

just aren't as good as those other

16:05

fields in part because we can get away

16:07

with not doing it as much. But we could

16:09

get some sort of fusion of the two and

16:10

get even better than we currently are.

16:12

Which, hey, plug for what I do. The

16:14

other thing that I think is more

16:15

interesting in terms of being a bit more

16:17

shocking to me is that while we're

16:19

better at being open about all of our

16:21

materials, we seem to be worse at

16:24

compiling

16:26

information about the specifics of our

16:29

job. And that's a bit loosey goosey, but

16:32

the example I keep coming back to is

16:33

that one of the engineers I talked about

16:35

two favorite books. the design of

16:37

everyday things which he recommends

16:38

every engineer read and the snap fit

16:41

handbook. Are you familiar with snap

16:42

fits?

16:43

>> No.

16:43

>> Looking around here to see if there's

16:45

like one if I could just show it. But

16:46

like you know like how remotes they have

16:48

that little clicky thing in the back

16:49

that you use that hold the battery in.

16:50

>> Yeah.

16:50

>> That's a snap fit. [clears throat]

16:52

>> It is a physical device that basically

16:54

clicks into another device to keep them

16:56

used. And this was a 500page book all

16:59

about snapets, their engineering,

17:01

appropriate shapes, materials, etc. And

17:03

that kind of compiling of information

17:06

about the materials is something other

17:07

fields do that we don't do. An analogy

17:09

that I would think of in software would

17:11

be something like a 500page book on how

17:12

to version an API.

17:14

>> We could all use that.

17:15

>> Yes, we could.

17:16

>> And and we don't have it.

17:17

>> We could learn it from engineering. We

17:19

should have that.

17:19

>> You started this project asking are we

17:21

really engineers? And your personal

17:23

inclination, which you didn't say at the

17:24

time, was that we're probably not in the

17:26

closing of this series. You said you're

17:28

still a bit unsure of how to answer it.

17:30

This was 5 years ago. this many years

17:32

later, what is your inclination? Are we

17:34

actually engineers?

17:35

>> I think so. I think this project and

17:38

writing about and thinking about it has

17:39

firmly moved me from the camp of we are

17:41

definitely not to we probably are. I do

17:44

want to caveat that I wrote this before

17:46

LLM's thing and this has probably

17:48

changed our field as we know it and it's

17:50

probably also changed those other

17:51

branches and I don't know how. So that

17:53

could have changed the calculus between

17:55

two spaces. But as of now, I think

17:58

excluding LLMs and how they're changing

18:00

things, what we do now is very similar

18:02

to what those people in those other

18:04

fields did according to my interviews.

18:07

It's it's such a cool project and it's

18:08

still a very good read. Uh I'll also

18:10

link it in show notes below. I I do

18:12

recommend going into it. So let's talk

18:14

about formal methods. How did you get

18:16

exposed to them? And for those of us who

18:19

are not deep into it, what are they? I'm

18:22

going to give you a function max, right?

18:24

Which should given a list return the

18:26

largest number. What would be a test

18:27

you'd write for that?

18:28

>> I' I'd write a test that I do a list of

18:30

like two items. It returns the the

18:32

largest one that I know. I give a very

18:34

long list. I I try to stress test it. I

18:37

I I give a list where I give like

18:38

similar numbers. I try to come up with

18:40

some edge cases. I'll I'll probably

18:42

write like five tests, try to think

18:45

about integer overflows, potentially try

18:48

some tricky, but maybe I'll take it to

18:49

maybe eight if I'm feeling super

18:51

ambitious and then I'm done.

18:53

>> Okay. So, when we take one of those

18:54

tests, how do you know what the right

18:56

answer is supposed to be?

18:57

>> I just know because I have a I I learned

19:00

math. So, uh in school I I know which

19:03

which number is bigger. Honestly, I I

19:06

look at it I have this I guess ingrained

19:08

knowledge. It feels very basic knowledge

19:10

that I don't even have to explain.

19:12

>> Right? You have some ingrained knowledge

19:14

that you don't have to explain such that

19:15

you can look at say the max of two and

19:18

three and know it's three. Right?

19:21

That's interesting. There's some sort of

19:23

implicit mechanism in your brain that

19:25

can see that and know what the function

19:26

is supposed to do. Step one of what I do

19:28

with methods is asking can we take that

19:30

implicit knowledge and make it explicit?

19:32

Can we figure out what a function is

19:34

supposed to actually be doing and write

19:36

that down in a way that can be shown to

19:38

anybody. So I would basically in this

19:41

process say like the max of a list is an

19:44

element that is in the list such that

19:46

every other element is smaller than that

19:48

element. That is a way that we can

19:50

formally say what the maximum of list

19:52

is. So that's part one just learning how

19:54

to look at functions and say like okay I

19:56

know what this is doing. How would I

19:57

explain what this is doing in a way that

19:59

is clear and unambiguous?

20:01

Then step two is asking every single

20:04

test you've written is basically some

20:07

facet of it is an element of the list

20:09

and it is the number in that list such

20:12

that every other number in the list is

20:13

smaller than it. Now that we have that

20:15

what's the best way to show that our

20:17

function actually satisfies that

20:19

specification. Tests are one way. Those

20:22

are basically taking individual values

20:24

and showing how those component

20:25

specification. Types are another way. we

20:28

could basically say like okay in every

20:29

single case we are putting in a list of

20:31

elements and we're getting out a single

20:32

element. So we have to make sure that

20:33

every time we call it that's what's

20:35

true. So basically the coming up with

20:36

the the properties of the thing like

20:38

what it actually is is the specification

20:39

of it and then showing the function

20:41

matches that specification is the

20:43

verification and what f methods ask is

20:45

can we use mathematics to show that it

20:47

works not just for the cases that you

20:49

asked for but every single possible list

20:52

you pass in. And that is done through

20:54

proof. Coming up with some sort of

20:56

mathematical argument that this code

20:58

matches this spec.

20:59

>> And then in proof, again from

21:01

university, I still remember the the

21:03

maths proofs where we would proof an an

21:06

equation. You do rigid transformations.

21:10

You know what you're allowed to do.

21:11

Sometimes you can bring in tricks, but

21:13

those tricks are also inside of your

21:16

rigid list. And every time, you know,

21:18

you typically start from a complicated

21:20

equation and you keep changing it. And

21:22

in the end you you shape it in a way

21:23

that it's now trivial or or you

21:26

transform. Those are one of the proofs

21:27

we do. Is is this what formal methods

21:29

also does to some extent?

21:30

>> Yes. But you know how to basically add

21:33

two tangent numbers by hand, right? Do

21:35

you do that by hand or do you just use a

21:36

calculator?

21:37

>> I now use a calculator. If it's easy

21:39

enough, it might I use my brain as a

21:40

calculator. Otherwise, I just punch it

21:42

into the calculator.

21:43

>> Yeah. So similarly a lot of pro methods

21:45

that math of transformation while you

21:47

can do it by hand with like what's

21:48

called a theorem provert often in

21:51

industry that it's being done for the

21:53

most part with tools that basically

21:55

automate huge parts of this process. So

21:57

you don't have to do every single

21:58

transformation yourself. You can for

22:00

example say okay we have these things

22:02

are true at the beginning I want this to

22:04

be true at the end and can you figure

22:06

this out and it'll be like either yes I

22:09

can prove these things match or no I

22:10

need a little bit more help. And you say

22:11

like okay at this point I'm going to

22:13

also let you know that this is true and

22:15

like okay I can verify that's true and

22:16

it helps me get to the end and you just

22:18

keep doing that until you actually have

22:20

enough that the computer can do the

22:21

proof for you.

22:22

>> Yeah. So with formal methods this I mean

22:24

this sounds all logical I think is easy

22:26

easy to follow in practice. What

22:29

techniques technologies tools does the

22:32

industry use the tech industry use to

22:34

actually prove that you know some some

22:37

stuff works?

22:38

>> To get to that we need to ask another

22:39

question. Why isn't this being done for

22:41

everything?

22:42

>> Okay, let let me ask that question.

22:44

That's a good question. Yeah, this all

22:45

sounds sounds sensible. It would be nice

22:47

to not have to write out those five or

22:49

eight tests. And I know that those tests

22:51

might not cover all edge cases. Been

22:53

there, done that where you miss and I I

22:56

I didn't think that I didn't do a formal

22:57

proof. I thought like, well, I missed a

22:59

test case. That's on me. Sorry. Let me

23:01

put in that that test case. I now have

23:02

nine tests and now I go and think I did

23:04

a great job. Why are we not doing formal

23:06

testing for everything? Instead of

23:08

finding the largest number in a list,

23:10

why don't we try to find the file in a

23:12

directory that has the most lines in it?

23:15

>> Well, now I'm thinking of writing a

23:17

program that in kind of an imperative

23:19

style, it goes through a four list. Each

23:21

each file, I list how long the the lines

23:24

are. I count the lines. I cannot tell

23:26

easily.

23:27

>> Okay. Are we talking about asky lines or

23:28

UTF at new lines? What happens if one of

23:30

the files you don't have the file

23:31

permissions to read it? Should you

23:32

basically ignore it or should you say

23:33

like, hey, my proof my my um function

23:35

might be wrong.

23:36

>> You're now trying to What if one of the

23:38

files is a shortcut to another file?

23:40

What if it's actually directory?

23:41

>> Damn, you're now simulating a binary.

23:43

>> You're now simulating real world.

23:45

>> Yes. And that's the problem we have is

23:46

that when you start talking about like

23:48

most interesting domain problems, you

23:50

have to pull in so much context that

23:52

basically even writing what the function

23:53

is supposed to do becomes a nightmare.

23:55

The imperative program you write that

23:56

will get correct 99% of the time is

23:58

probably good enough to use in almost

24:00

all cases. And if you want something

24:01

that works 100% of the cases, you've got

24:03

to figure out, okay, what file system

24:04

are we using? You have to figure out

24:06

everything.

24:06

>> Yeah. And that's why it's

24:07

[clears throat] not done

24:08

>> and basic it would just not be

24:09

practical. It would be for the for 99%

24:12

of the people would be why are you

24:13

wasting your it's like premature

24:15

optimization right?

24:16

>> Yeah especially when as you say writing

24:18

10 tests might get you most of what you

24:20

need. What are practical technologies

24:23

that you have seen used in some part of

24:25

the industry that even though they will

24:28

I'm assuming will be somewhat

24:29

heavyweight because it sounds like

24:30

pretty heavyweight. It might be the

24:33

return the return of investment of using

24:35

this heavyweight stuff is worth it that

24:37

teams in industry are using it today

24:39

right and here we can basically start to

24:41

break this down to different parts of

24:42

the landscape. So, one part is to look

24:45

at the stuff that actually does need to

24:48

be verified to that degree. And the

24:50

usual term here is nukes and NASA like

24:52

nuclear power plants and like um NASA,

24:55

but I can tell you with firsthand

24:57

experience, nuclear power plants do not

24:58

care about this stuff. They're actually

25:00

just fine with with with thorough

25:01

testing.

25:02

>> Okay. Okay. So, then category two is

25:04

like really focused cores of programs

25:06

where they need like one specific part

25:08

of the program to be like really

25:10

verified and the rest of it they can use

25:11

informal methods. And this is usually

25:13

things that are like um small parts of

25:16

databases or like cryptographic

25:17

primitives. I believe that the HTTPS

25:20

stack in Firefox is verified as part of

25:21

something called Project Everest, but I

25:24

might be getting some details of those

25:25

wrong.

25:25

>> Would an operating system kernel fall

25:27

into this or maybe just a very key

25:29

specific part of a kernel like memory

25:31

allocation or something like that?

25:32

>> Yeah, parts of um operating system

25:35

kernel are good uses for this. Um, a

25:36

couple examples I can think of is I

25:37

believe Microsoft used some

25:40

polarification of parts of their beasta

25:41

kernel for the driver loading. Famously

25:43

there was an operating system called4

25:46

that has been endto-end verified in a

25:47

language called Isabel. It's a micro

25:50

kernel. It's very small. It's mostly

25:51

used for um automotive and military

25:52

applications but it is a fully verified

25:55

operating system with a caveat meaning

25:57

that it's matching the specification. So

25:59

it might do the wrong thing but of the

26:01

things that you specify that it has to

26:02

do right it will do those specific

26:04

things right in the right circumstances.

26:06

The last category is the kind I work in

26:08

which is asking okay what if instead of

26:11

verifying the entire real world system

26:13

which is a nightmare as we just

26:15

discussed. We create a simplified

26:17

version of the system and verify that

26:19

then the actual system might still have

26:22

bugs but we can iron out the issues in

26:25

the abstraction such that we don't

26:26

actually build them in the real system.

26:28

And and so that that's a topic where you

26:31

are planning a system and you want to

26:33

stress test it to iron out.

26:35

>> Yeah. Stress test the plan.

26:37

>> What what kinds of plans would these be

26:39

roughly? Is is it planning like again

26:42

database or or some sort of distributed

26:44

system? In my work, it's mostly been um

26:47

databases and distributed systems for

26:49

technology companies, but I've had some

26:51

other like interesting gigs. Like I've

26:52

had one gig that was involving formally

26:54

verifying um firmware of a device

26:57

kernel. And one honestly, one of the

27:00

coolest projects I ever worked on was um

27:01

verifying the transponders of a train

27:04

system to make sure that they wouldn't

27:06

cause problems to trains going over

27:07

those transponders. That was a lot of

27:08

fun. We found a really old bug in that

27:11

one, too. That was kind of exciting.

27:13

This whole episode is about a question

27:14

that only gets more important as AI

27:16

writes more of your code. How do you

27:18

know if it's correct? And for some parts

27:20

of a codebase, you really don't want an

27:22

AI model to be taking guesses at O is on

27:25

top of that list. And this is where I

27:27

need to mention our season sponsor, work

27:29

OS. If you're building any SAS,

27:31

especially an AI product, you'll need O

27:33

for apps and agents. This is the layer

27:35

where close enough is just not good

27:37

enough. So don't [snorts] let this layer

27:39

get improvised by AI. Worker gives you

27:41

the proven implementation SSO skim and

27:43

fine grid authorization built for how

27:45

agents operate and in a way that's easy

27:47

for them to integrate with an

27:49

implementation that you can trust. Check

27:51

it out at work.com.

27:53

I also want to talk about our season

27:54

sponsor Turbopuffer. But this time I

27:57

don't want to talk about how they are

27:58

fast, cheap, and extremely scalable

28:00

search engine built on object storage.

28:02

Instead I'd like to talk about their

28:03

team. I interviewed Simon, the

28:05

co-founder and CEO, on stage at AIGO's

28:07

World Fair and also hung out with their

28:08

team for a few days in person. Here's a

28:10

few the interesting things I learned

28:12

about them. The company is full remote

28:14

yet feels pretty connected. They have a

28:16

Slack first culture. For example, all of

28:18

their customers have a dedicated Slack

28:20

channel and engineers are in these

28:21

channels seeing feedback from these

28:23

customers, often fixing their bugs. The

28:25

team gets together for annual summits at

28:27

least twice a year and campfires form

28:30

several times a month anytime several

28:32

remote employees gather in the same

28:33

city. Simon describes their engine

28:35

culture as hardcore and whimsical. They

28:38

focus on solving difficult problems but

28:40

also try to have fun. A good example is

28:41

the pragmatic engineer landing page that

28:43

they built. We agreed to have a custom

28:45

landing page and then their team decided

28:46

to build a cool logo that animates on

28:48

mouse movement. Another interesting

28:50

thing is their team composition. Pretty

28:52

much everyone currently working at the

28:53

company has 101 15 years of experience.

28:56

For a startup, they are an unusually

28:58

seasoned team. Finally, I really

29:00

appreciate how pragmatic their

29:01

engineering philosophy is. Simon and the

29:03

team strongly believe in how simplicity

29:05

scales and this is a reason that object

29:07

storage is Turbopuffer's only

29:09

dependency. The team do seemingly silly

29:11

things like build their job QE in a

29:13

single file on object storage because

29:15

they understand the core primitives and

29:17

they know how they scale. to check out

29:19

the whimsical animation or if you're

29:21

building AI products, head to

29:22

turbopuffer.com/pragmatic.

29:25

And with this, let's get back to how TLA

29:27

Plus works with a demo from Hill. Can we

29:30

see a demo?

29:30

>> Okay, sure. So, I've got a couple

29:31

languages with me. Um, the kinds that

29:33

I've worked in. So, the most popular

29:34

technology right now for that kind of

29:36

planning is this language called TA

29:38

Plus. It was invented by Leslie Lamport,

29:40

the same guy who made Latte, the um type

29:42

setting language actually.

29:43

>> Oh, yeah. All the PDFs behind the scenes

29:45

are are latte. Yeah, Pet Caesar Latte

29:48

and he wanted a language that could be

29:50

used to model distributed systems. So he

29:53

basically created this thing called TA

29:55

plus temporal logic of actions plus

29:57

everybody always asks about the name.

29:59

You don't need to know the name just

29:59

known as TLA plus. And what it does is

30:02

it basically represents the state

30:04

machine of a system. Every possible

30:06

state it can be in and every possible

30:07

state it can it can transition to. Then

30:10

we can use a brute force model checking

30:12

where we basically find every initial

30:14

state and every state that can evolve

30:16

from those and check if they have

30:17

properties. TA plus is unique in some

30:19

ways because it has certain properties

30:21

like checking livveness and refinement

30:23

that we won't get into. But let's

30:24

actually see a demo right now. So this

30:26

is one of the demos I like to use to

30:28

showcase this. And

30:30

we in this demo we have a simple model

30:33

of a trading platform. Each person on

30:36

the platform has a set of items and they

30:39

want to trade these to other people. The

30:42

way that we're going to show the

30:43

simplified system is that each item is

30:46

assigned to a person. There's also a set

30:49

of outstanding offers. We're only going

30:51

to model sending items to people, not

30:53

swapping items.

30:55

If you propose an item, you have to own

30:58

that item and it's basically added to

31:00

the set of offers. And then you can

31:02

accept an offer. If that offer is

31:05

available, you remove it from the set of

31:07

offers and the owner transfers.

31:11

If you reject the offer, it's just

31:13

removed from the set. Then we define

31:16

what can happen next.

31:18

A next state as in one of the ways the

31:21

system can evolve is we pick some two

31:24

people that are different. That's what

31:26

this from dash equals 2 means. and some

31:28

random item and either you propose that

31:30

item, accept a proposal for that item

31:33

which must already exist or reject an

31:35

existing proposal.

31:37

Below we have a property that a valid

31:40

change is one where if the owner changes

31:44

it is because

31:46

the new person accepted an offer from

31:48

the old person. So if the item goes from

31:50

you to me it's because you offered it to

31:52

me and I accepted that offer. And the

31:55

finally we have a change invariant some

31:56

property of the system saying every

31:59

change is a valid change. Now what's the

32:03

bug in this?

32:05

>> Well, first of all, this has a learning

32:06

curve.

32:07

>> Yes, it has a learning curve. And that's

32:08

why this is fairly niche. And I should

32:11

probably point out right now that when

32:13

Leslie Dumper made this in 1994, he was

32:15

thinking of it mostly he was a

32:17

mathematician, right? So he was using

32:18

his mathematical like background and

32:21

like learning how a mathematician would

32:23

write some symbols. In the 30 years

32:25

since that point it's been 30 years

32:27

since 1994 already. A lot of languages

32:30

have been developed in part from the

32:31

lessons of learn of TA plus that make

32:33

things a little bit more appealing to

32:35

programmers. So you have things like

32:36

Quint and P which are languages that

32:40

look more like programming languages and

32:42

are easier for people to gro. The reason

32:43

a lot of us used TA plus was because

32:45

like the first really high-profile

32:47

demonstration of this kind of work in

32:49

practice was an Amazon paper, the use of

32:51

formal methods at Amazon Web Services in

32:53

2014 and they used TLA plus for this. So

32:57

that's what a lot of us just have

32:59

originally started on.

33:00

>> So going back to this, there is a bug in

33:02

this one with with with all the

33:04

associations and how can we how can we

33:06

figure out what the bug is? Will will

33:09

the system help tell us or or we now

33:11

need to think through what case we miss?

33:14

>> Well,

33:16

if we had to think through it ourselves,

33:17

we wouldn't be using this nasty syntax,

33:18

would we?

33:19

>> Nope.

33:20

>> So, what I've done is I've also written

33:22

a quick um configuration file saying

33:25

take a specification,

33:27

take these three people, Alice, Bob,

33:29

Carl, and have them trade around a

33:31

stick. And then I tell it, make sure

33:33

this property that the change in variant

33:35

always holds.

33:36

>> Always holds. Now I just have to run

33:37

this.

33:41

I'm also having it output the state

33:42

space for you so you can see what that

33:44

looks like. And it just puts out the

33:46

error for us. It says the property has

33:48

been violated. It took 53 states to find

33:50

it. And the way it works is

33:54

it's on a small screen so it's being

33:56

word wrapped. But if I see it kind of

33:58

looks like this. Essentially the error

34:00

is as follows. And let's actually see if

34:01

the error I can show it to you with the

34:04

um dot file.

34:07

as um biz graph is not dotiz what am I

34:11

saying?

34:13

So this is just um a preview of the

34:15

state space it's generating.

34:21

So you can see it's basically generating

34:22

every possible state it can find. This

34:23

isn't the whole state space. Usually

34:25

because these the state traces end up

34:26

being like 100 million states for like

34:28

in the state space. Usually these aren't

34:30

that useful. It's mostly a thing that we

34:31

have for that we sometimes use for

34:33

demos. So, the error is as follows.

34:36

Alice, Bob, and Carol are on the system,

34:38

and Alice owns the stick.

34:40

>> Yep.

34:41

>> Alice makes an offer to Bob. Bob is

34:43

away. Alice gets tired of waiting for

34:46

Bob to come back to make the offer

34:47

because she wants to get rid of her

34:48

stick. She makes the offer to Carol.

34:51

Carol immediately accepts. So, the stick

34:53

transfers from Alice to Carol. Now, Bob

34:57

comes back, sees the offer from Alice to

34:59

Bob and goes, "Oh, yeah. I want that

35:00

stick." Clicks the button, and now the

35:01

stick becomes Bob's. But it did not

35:03

transfer from Alice to Bob, it

35:04

transferred from Carol to Bob. So the

35:06

change in variant that if the stick went

35:08

from Carol to Bob, it must be because

35:10

Carol made an offer that Bob accepted

35:12

was violated. And therefore the system

35:14

raises an error.

35:16

>> And then how did the system simulate

35:18

this? It had to simulate a state where

35:21

Bob was waiting or or didn't respond for

35:25

a while and responded later.

35:26

>> We basically assuming we start in the

35:27

state of basically Alice owns the stick.

35:31

There's two possible things that can

35:33

happen here, right? We have offer Bob.

35:38

>> Yep.

35:38

>> And we have offer

35:41

Carol, right? So those both happen and

35:44

those are both distinct states. So the

35:46

model checker says, okay, I'm going to

35:48

create two new states. Then from this

35:51

top one of offer Bob, there's three

35:53

things that can happen. We can have Bob

35:55

accept

35:58

>> Bob reject

36:00

or and this is where the concurrency

36:01

comes in. We can do offer Carol, right?

36:03

>> Yep.

36:06

>> I see.

36:06

>> Yeah.

36:07

>> Mhm. I I see where this is coming. And

36:09

then when you continue, we will hit the

36:11

bug.

36:11

>> Yeah.

36:12

>> The change in variant will be invalid at

36:15

whatever step that is run at.

36:17

>> Right. And that's actually where a lot

36:19

of this like becomes useful for

36:21

distributed systems because often it'll

36:22

be like okay process one can do one of

36:25

six things, process two can do one of

36:26

six things, process three can do one of

36:27

six things. And when you do this root

36:28

force you get states like process one

36:30

takes step one, then process one takes

36:31

step two, then process two takes step

36:32

one, then process one takes step three,

36:34

then process three takes step one and

36:35

two, then process two takes step two and

36:37

three, etc. And being able to sort of

36:39

see every possible iteration of that is

36:41

very hard for human beings to do, but a

36:43

computer with enough CPU can just brunch

36:44

through to in a night or two.

36:46

>> Yeah. So, so this is what TA plus is

36:49

then.

36:50

>> Yeah, basically.

36:52

>> And one story I've heard and I think you

36:54

might have been involved is AWS uh using

36:57

TLA plus. Can you talk about how they

37:00

onboarded, how they're using it, what

37:02

they're using it for as far as you're

37:03

aware?

37:04

>> Yeah. So the seminal paper on this was

37:07

in 2014 the use of foral methods in

37:10

Amazon web services and they talked

37:12

about how a couple of people in the

37:13

company were interested it and learned

37:15

TA plus another language called pluscow

37:17

which is something that compiles TA plus

37:19

and applied it to aspects of the Dynamo

37:22

Dynamob and S3 storage systems. In doing

37:26

so they were able to find fairly

37:27

complicated bugs that could potentially

37:29

lose data and I think it was in the

37:31

replication system. In the paper it said

37:33

that the shortest error trace exhibiting

37:36

the buck contained 35 highle steps which

37:40

if I understood that correctly it was at

37:42

at a depth that it would have been very

37:43

hard for a human to p persevere or you

37:46

would have need to be really determined

37:48

>> and precise.

37:49

>> I did not work on that project of course

37:51

so I don't know what the details are. I

37:52

can speculate that the reason it found a

37:54

35step bug was because the state base

37:56

was probably 100 million states wide. So

37:58

there were like plenty of say like 70 or

38:01

80 step chains that were totally safe

38:02

and it just happened this 135st step

38:04

chain was invalid.

38:05

>> Through working with a lot of customers

38:08

and and and teams that that have used

38:10

form of verifications with distributed

38:13

systems, what are some problems you've

38:16

come across with distributed systems

38:17

that might be a bit of a repeat pattern

38:19

of of you know how they break down or

38:21

why they break down? If I can think of

38:22

like one thing that like besides like

38:24

just general race conditions and locks,

38:26

this is the one that like is always a

38:27

new pull was like yes, it's another time

38:30

to allow a time to check the time to use

38:31

bug. And time to check time to abuse is

38:33

a situation where you are checking to

38:36

see if something is like valid can be

38:37

done validly and then you see that it's

38:39

correct and then a little bit later you

38:41

do it. Sometimes that little bit later

38:42

is like a day later. Sometimes it's a

38:44

microcond later. But is any case where

38:46

it is possible for something to go from

38:47

being valid to being invalid in between

38:49

the time you check and the time you use

38:52

it. A good example here is imagine

38:56

you're withdrawing like money from a

38:58

bank account and putting into another

39:00

bank account. And this is not how banks

39:01

work. I know they use a different kind

39:02

of ledger, but just as a demonstrative

39:04

example, you check, oh, do they have $10

39:06

in their account? Yes, we deduct $10. We

39:08

put $10 in this account. But what can

39:10

actually happen is you check, do you

39:12

have $10 in this account? Yes. And then

39:14

while you're still getting ready to

39:16

withdraw, somebody else quickly runs in

39:17

and grabs those $10 away. And now

39:18

they're $0 and now you deduct those $10,

39:20

you have negative $10. That's a time to

39:22

check the time to use kind of bug. They

39:24

happen everywhere.

39:25

>> Yeah. And it's very interesting because

39:27

I when we were building Uber's payment

39:30

system, I realized or I learned that the

39:33

problem of having a message delivered in

39:35

a distributed system exactly once is a

39:38

very difficult one because typically

39:40

that's what you need when you want to do

39:42

one one charge. You want to charge a

39:44

customer's card exactly once because if

39:46

you send multiple messages just in case

39:48

one of them gets lost, you now have

39:50

double charges. And turns out it's a

39:52

it's a complicated problem. It's a lot

39:55

easier to do at least once delivery.

39:58

>> Yeah.

39:58

>> Than exactly one's delivery. But of

40:00

course you need exactly at least one's

40:02

delivery to build on to create exactly

40:05

one delivery.

40:07

>> Yeah. I wonder if this is why like a lot

40:09

of like um businesses they just charge

40:11

you extra and then refund you some

40:12

amount that seems like easier to do from

40:15

an engineering perspective as as well.

40:17

It's also from a risk perspective you

40:20

eliminate a lot of uh edge cases by

40:22

authorizing upfront on a credit card you

40:24

have a credit limit and if you would

40:27

authorize exactly how much you think you

40:29

need right now but you need a bit more

40:31

you might get into that edge case where

40:32

later you have trouble authorizing it.

40:34

This is why often hotels don't want to

40:36

deal with this. So they just authorize a

40:37

larger chunk and they know because it's

40:40

it's a larger amount for hotels.

40:41

Otherwise they might have run into the

40:42

thing where you would run out of your

40:44

credit and now they have to do a

40:46

separate flow. But you're right some

40:48

engineuring decisions might happen

40:49

because it's easier to do some some

40:51

stuff.

40:52

>> Yeah, it makes sense. I honestly thought

40:54

hotels did that because they were trying

40:55

to convince you not to like break stuff

40:57

because like hey if if you know that

40:58

you're definitely going to lose $800 if

40:59

you break something like you're not

41:00

going to break stuff.

41:01

>> Through working with engineering teams

41:03

who are building distributed systems and

41:04

you're coming in and helping them learn

41:06

TA plus uh learn how to survive things.

41:08

What have you learned about how they

41:10

usually think of verifying distributed

41:13

systems before they learn about formal

41:14

methods and what changes after? So I

41:17

think the most interesting thing about

41:20

formal methods and how it affects how

41:22

you build systems isn't the theory of

41:25

the method or how it makes you think

41:26

about systems. It's the practice. Why is

41:29

concurrency hard? Why is it hard for us

41:31

to reason about concurrent systems? Why

41:33

why do you think it's hard?

41:34

>> I think it's hard to keep several things

41:37

in your mind of like where they could

41:40

be. That's one. Or maybe we just don't

41:42

really have a mental model of how to

41:46

draw them out. I guess whiteboarding

41:48

would be a way to do it. But I I don't

41:50

remember whiteboarding on concurrent

41:51

system. I remember whiteboarding just

41:53

boxes and and imperative. This

41:56

flowcharts are good for whiteboarding.

41:58

So this is something that I've wondered

41:59

a lot, right? Like why it's hard for us

42:01

to deal with these systems. And I'm not

42:04

sure it's because it's hard for us to

42:06

think about them. I mean like when you

42:08

cross the street, aren't you working

42:10

with concurrent system? You're just

42:12

there's cars everywhere. They're going

42:13

to hit you. You're going to die if you

42:14

don't model concurrent system in your

42:16

head. And there's actually this really

42:18

cool paper I found called common sense

42:20

computing where some people were trying

42:22

to figure out like how people thought

42:24

about concurrent systems. when talking

42:25

with like sort of like high school and

42:26

college students, they changed the

42:28

concurrency problem from like, hey,

42:29

we've got these threads doing some

42:30

operation to like, hey, we've got these

42:32

like clerks at a ticket office assigning

42:35

seats at a concert. People saw the bug

42:37

much faster. So, I do think we can

42:40

actually get quite good at seeing

42:42

concurrency issues. I think a large part

42:45

of the problem of why it's hard for us

42:47

is because we don't get a lot of

42:48

practice. Usually when you have a race

42:50

condition in a system, you find out

42:52

months later and then you try a fix and

42:55

you find out weeks later after that if

42:56

the fix actually worked. Whereas with

42:58

the TA plus like I write my model of the

43:00

system and then I click a button and

43:01

immedately tells me hey race condition

43:03

and then you fix it and it says like hey

43:05

timeout bug and then you fix it again

43:06

and says hey to bug and that feedback

43:11

loop ends up being so much faster than

43:12

you get in practice. And I think that

43:14

more than anything else helps people

43:16

find race conditions more easily and

43:18

think about problems and distribute

43:19

systems more easily. I've found

43:22

personally that when I work with new

43:24

clients and we're modeling their system,

43:27

I usually have no idea how their system

43:28

works, right? Because they're the domain

43:30

experts. I just have know this really

43:31

weird funky language made 30 years ago.

43:34

But once we actually have the model, I

43:36

can see the bug in the model much faster

43:37

than they can, even if it's their system

43:40

simply because through this work, I've

43:41

had so much more practice with it. And I

43:44

think that's the main change in how it

43:45

affects people's ways of thinking about

43:46

distributed systems. It gives them

43:48

actual practice of seeing how those

43:49

systems can go wrong so much faster.

43:52

>> I wonder if it's a little bit like

43:54

refactoring and also migrations. So

43:57

refactoring a codebase when you are

43:59

starting out as a developer and you need

44:00

to do a refactoring by by hand you know

44:03

let's say just changing a function name

44:05

and then you need to go and change all

44:06

the reference to that function and the

44:08

first time you do it you change it at a

44:10

few places and then you forget about the

44:11

rest and either it's a compilation issue

44:13

or if it's a dynamic language it's a

44:15

another problem but then you get good at

44:17

it once you practice with migrations

44:19

most engineers that I've seen are

44:21

terrible at migrations because you need

44:23

to make a plan you need to do check you

44:25

can do shadowing reverse shadowing all

44:27

all that funk and then there are a few

44:29

engineers who have done three or four or

44:31

five and then you they closed their eyes

44:32

and and they can just do it. I'm just

44:34

thinking that when it comes to race

44:35

conditions most of us I I I was exposed

44:37

to race conditions by oh we did a double

44:40

charge that one and then we found the

44:41

race condition

44:42

>> but I I never did a second one like so

44:45

so I I I I will not be good at finding

44:46

race conditions. I I'm not even good at

44:48

thinking about them.

44:49

>> I think that's right on the money. It it

44:50

sounds like you coming into teams or or

44:53

to these clients it you at least give

44:56

them some practice the very least of of

44:58

how to think about this category of

45:00

errors even assuming that the taking out

45:04

even the tooling itself.

45:05

>> I think there's also like more subtle

45:07

things that you start to pick up from

45:08

these tools but I think that's like the

45:09

most visceral one the visceral like

45:12

hatred of a race condition that gets a

45:14

like physical presence in the algorithm.

45:16

you've been doing this for for very

45:18

long. You're for you writing TLA plus is

45:20

is like for most of us writing

45:22

TypeScript or or the language that we're

45:24

familiar with. How has your thinking

45:26

changed? And is there any similarities

45:28

between when you program an imperative

45:30

language and then you learn a different

45:32

one like a declarative language which

45:34

requires a very different thinking?

45:35

>> Mhm. And that also depends on

45:36

declarative language. Like I've I've

45:38

I've done a lot of stuff in like logic

45:40

programming languages and like I've done

45:41

some stuff in like array languages, but

45:43

like you show me CSS and I'm just like

45:45

what is this dark magic declarative?

45:48

What are you talking about? I think so.

45:50

Um it's going to be hard to sort of pin

45:51

down exactly what though. Like my usual

45:54

haggling language is Python these days

45:55

just because that's like one of the

45:56

first things I use and I just know it

45:57

very well. And I think like at the very

46:00

least like the for methods makes me much

46:02

more willing to reach for mathematical

46:03

solutions or like math heavy solutions

46:05

than like simple reliable solutions.

46:08

>> Math is also an interesting topic. Uh

46:10

you've recently had a bit of back and

46:12

forth on whether developers,

46:14

programmers, software engineers should

46:16

learn math. There was a bit of a

46:18

discussion back and forth. Could we talk

46:19

about the the core of the argument?

46:21

>> How math is useful in programming is a

46:23

very interesting question. Right? So

46:24

first of all, there's math that we all

46:26

find so useful we forget that it's

46:27

actually math. Like counting, counting

46:30

is math. Knowing whether one thing is

46:32

bigger than another number is math,

46:34

right? It's just math that we have been

46:35

taught from a very young age because it

46:37

is so important that no matter what

46:39

you're doing in life, you need that

46:40

math. Then there's a lot of math that is

46:43

useful for very specific specialist

46:44

jobs. Like I've talked to some SR who

46:47

need calculus, but I think most

46:48

programmers do not need calculus. There

46:51

are some branches of math that are

46:52

useful in a wide range of programming. I

46:54

think things like understanding graphs

46:55

and directed graphs, knowing matrices,

46:58

knowing formal logic can be very useful

47:00

for a lot of different people, but I

47:03

think it is more useful for most

47:04

developers to have an exposure to like

47:06

what math has in the various fields

47:08

versus just going all on every single

47:10

field when they see them, right? You've

47:12

got to know what's available to know

47:13

what's most useful for you. And most

47:15

math will not be useful for you. It's

47:16

also very interesting because for a long

47:18

time I I thought at university we had

47:20

pretty heavy math education for computer

47:22

science from algebra to computitional

47:25

theory to form even even formal methods.

47:27

at university I I learned a bunch of

47:29

advanced math and at first when I came

47:30

into industry it wasn't particularly

47:33

useful or I didn't use it day-to-day but

47:35

then there are some times where it's

47:37

kind of useful for example matrix

47:39

transformation I learned 3D graphics and

47:41

I how you compute all the points based

47:43

on 3D matrix transformations and then it

47:46

helped me understand when GPUs were

47:48

becoming so popular with AI why this is

47:50

because they're also very good at matrix

47:52

transformations which happens to be

47:54

pretty similar so every now and then I

47:56

feel it it helps with your general

47:57

understanding and it helps you be

47:59

unafraid to go into deep. So if I see a

48:02

a paper with formal proof, I'm not going

48:04

to shy away from it. I can start reading

48:06

it and I will know my my limits, but I

48:08

have that understanding. And I think

48:10

going back to our discussion with the

48:11

crossover project, I wonder if it helps

48:13

you connect closer with other other

48:16

engineering disciplines in terms of you

48:18

can understand more things there. For

48:20

example, for electrical engineering, you

48:22

you do have math involved that is there

48:25

to describe and if you will want to have

48:29

the vocabulary to understand that part.

48:31

One of the interesting things at least

48:32

about the mathematical differences is

48:34

that in almost every traditional

48:36

engineering field, the math they need is

48:38

continuous math analysis, things like

48:40

differential equations and calculus. And

48:42

that in the United States is what's

48:44

taught like at an advanced level in high

48:45

school if you get that far is this kind

48:48

of continuous math. In software

48:50

engineering and computer science, the

48:52

math we most often use is discrete math.

48:54

things like combinotaurics basically

48:56

which is the math of counting things

48:58

graph theory formal logic set theory

49:02

things that work with discrete entities

49:04

which isn't usually taught at least in

49:07

the American high school very much or

49:09

even early in university mathematics

49:12

classes and I wonder sometimes if that

49:14

is the reason people don't recognize the

49:16

use of math and software engineering is

49:18

because the math they do need is not the

49:20

math they've been exposed to

49:21

>> interesting yeah because the math that I

49:23

did used more was common networks. Uh

49:26

and and of course like maybe these days

49:29

those entries are going out of style but

49:31

there's the here's a problem build an

49:33

algorithm that solves it and then you

49:35

ask like okay how efficient is this

49:36

algorithm and then there's the big old

49:37

notation we we have the language to

49:40

describe how efficient in in in space

49:42

and time is and you can do tradeoffs and

49:45

you can and once two people know the

49:47

same thing you can have discussions

49:49

about these things and it's it's on one

49:51

end it's very abstract but on the other

49:53

hand if you're close to the machine it

49:54

can be very useful. I've also found that

49:56

like my understanding of bigo notation

49:58

got a lot better once I understood the

49:59

mathematics behind it because I think

50:00

it's usually explained as terms of like

50:02

oh this function scales at this certain

50:04

rate but like it is more formally a way

50:06

of describing a set of functions and

50:08

then there's the math of like how we do

50:09

asotics and stuff but like etc. I think

50:12

even like the technical aspects math

50:14

does help a lot in understanding those.

50:16

>> Yeah. And with the TLA plus

50:18

specifically,

50:20

what cases have you seen in the industry

50:23

TLA plus being a good fit for certain

50:26

problems and in what cases would you

50:28

ever consider it? I think the case of TA

50:30

plus and most not all but most methods

50:35

they shine the most in highly

50:36

computational domains where most of the

50:38

problems are

50:40

highly technical and not like

50:44

business embedded and what I mean by

50:47

that is that like how do you replicate

50:48

nodes between these two data sets is

50:50

like very technical right something like

50:53

I'm trying to think about like um a good

50:55

example here like how do we make sure

50:58

our sprints don't go overtime is very

51:02

business, right? It deals with like very

51:03

human behaviors. So, I've had to help

51:05

model client model that and we got some

51:06

use out of it, but it was very hard. So,

51:09

that's why a lot of my clients end up

51:10

being things like database vendors or

51:12

like cloud computing people who are or

51:14

like hardware people who are working in

51:16

a space that's like very important for

51:18

business, but several steps removed from

51:20

like the front lines of that business.

51:22

The other thing I would say is that

51:24

different tools are good at different

51:25

things. TA plus in particular tends to

51:28

be good at discrete distributed systems

51:31

where the main challenges are messing

51:34

with concurrency and possibilities

51:35

eventually being like behaviors. It

51:37

doesn't do floating point. It doesn't do

51:39

decimals. It doesn't do as well with

51:42

when you're trying to figure out

51:42

probabilistic things. Oh, that's another

51:44

thing I guess I should be saying is that

51:46

like where the kinds of errors you care

51:48

about are ones where like if it is

51:49

possible this error to happen, that is a

51:51

big deal. It's not good if like you're

51:53

like, "Okay, this error is bad, but as

51:54

long as it happens less than one out of

51:56

a 100 times, it's it's okay. It can't do

51:59

that kind of probabilistic reasoning for

52:00

you." There are tools that can, but they

52:03

lack things like functions or arrays

52:07

or numbers. Also depends on how much

52:09

time you need to spend planning. Like if

52:11

you don't need to spend that much time

52:12

planning, this is going to waste your

52:13

time. I I do want I do want to add that

52:15

that this like if you can iterate your

52:17

way through a solution and the bugs

52:19

aren't going to be that costly then you

52:21

might not need this tool. I I think it's

52:22

really important as like a person who

52:24

who talks about a really exotic tool to

52:26

like constantly emphasizing like no I'm

52:27

not trying to convince you to like use

52:29

something that's not a good choice for

52:30

you. I think a lot of the reason people

52:32

are skeptical of these is because

52:33

they've been burned by things like case

52:35

and UML and all these other miracle

52:36

solutions that were forced on them by

52:39

people who wanted them to use it no

52:40

matter what. And I think it's really

52:41

important to always say like if this

52:43

isn't the right tool for you, I am not

52:44

going to recommend it.

52:45

>> And then can we talk about other other

52:47

tools or can you show us a few other

52:49

ones?

52:49

>> Yeah. So the other tool I have installed

52:52

on this computer is called alloy and it

52:54

was made by an MIT professor.

52:57

Different format is lineage. Just like

52:59

there's many different kinds of

53:00

programming languages, there's many

53:01

lineages of formal specification

53:03

verification tools. So this example is a

53:07

simple access control system. So we have

53:10

a set of resources

53:12

and users who can read those resources.

53:15

Yep.

53:16

>> So each resource has some people who

53:17

it's reasonable by and resources may or

53:20

may not have a parent resource. L1 mean

53:22

L1 meaning less than equal to one

53:24

resource.

53:25

>> There are no cycles. So no resource can

53:26

have itself as a parent or its parents

53:28

parent as a parent.

53:29

>> Yep.

53:31

You can read access a resource if the

53:34

resource indicates you can read that

53:36

resource or if it's parent indicates you

53:38

can read that resource and we have a

53:40

property that if you can read a resource

53:43

you can read its children.

53:44

>> Yep.

53:45

>> This is has a bug. What is it?

53:49

>> I mean I I'm I'm glancing at this and

53:52

this all made sense to me. I thought

53:53

this is it cuz we're saying all of the

53:56

parents can access it. I'm assuming the

53:58

bug if if there is one is it will it

54:00

might have to do with something that we

54:01

talked earlier of like accessing in

54:03

certain areas. No idea. Can we run it?

54:06

>> Yes, we can. So this was actually made

54:08

in an earlier version of alloy just for

54:10

the just for context. Um alloy did not

54:11

have any sort of temporal reasoning over

54:13

state up until about 4 years ago. So

54:17

this is one examples I used from before

54:18

then of basically how you can analyze

54:20

and find bugs in static configurations.

54:22

An alloy that often means finding bugs

54:23

in data structures or in data models and

54:26

domain models actually. So there's

54:27

actually some interesting there's some

54:29

interest in this in the domain driven

54:30

design community I found. I'm going to

54:32

copy this over to alloy their IDE which

54:39

is a bit more rudimentary and that's why

54:40

everybody uses the VS code. Now, if I

54:42

execute this,

54:50

here's the counter example.

54:53

All right. And this is one of the nice

54:54

things about Ali specifically is that it

54:55

can generate like visualizations. So,

54:57

basically, here's the problem.

55:00

We have a user who can read a parent

55:04

resource.

55:06

The parent has a child because of how we

55:09

defined um can access we can read as

55:13

parent so we can read the child.

55:15

>> Yes

55:16

>> the child has a grandchild

55:18

we cannot read the grandchild.

55:21

So because we are not in we are not

55:24

assigned to the readable by for the

55:26

child only the parent. In other words

55:29

readable by is not transitive. So we can

55:31

read the child but not the child's

55:32

children. And that is the bug.

55:34

>> Mhm. and to visualize those for us.

55:36

>> Yes. Which is quite nice and one of the

55:38

reasons why people really like Alloy.

55:39

>> Nice.

55:41

>> It's a bit worse for modeling like

55:42

distributed systems though, which is why

55:44

most of my work is in TA plus.

55:46

>> And then to do the fix, what would it

55:48

involve? We would need to

55:51

give access to the children's children.

55:56

>> Yeah, there's a few different ways that

55:57

we could fix it. And often like pro

55:59

methods, they don't really tell you

56:00

here's how you fix it. It lets you

56:01

choose how you want to fix it. Like one

56:04

thing I could do is I could say okay I'm

56:06

going to say that

56:09

this is a transitive lookup too that we

56:11

transitively close over all parents and

56:13

if I execute that no more counter

56:14

example that said that might not be

56:17

something physically implementable I

56:19

might try to tell like hey people like

56:20

hey in our SQL database you have to have

56:22

a transitive query and our database

56:23

administer is like no that's going to

56:25

crash the database you can't do that

56:26

then we have to find a different fix

56:29

>> so this is the beauty of formal methods

56:30

yes it it it gives

56:34

gives you opportunities of how you will

56:36

implement fixes, changes, and then you

56:37

can rerun it again and see what

56:40

difference it made.

56:40

>> Exactly. Now, one quick fun fact. I love

56:43

just fun facts about stuff. You see how

56:45

this says solver SAT 4J. So, have you

56:48

heard of SAT SAT problems?

56:50

>> No.

56:51

>> Okay. Is there some variable that makes

56:53

the statement P true?

56:56

If I can make P true or false, is there

56:57

a way I can make that true? So let's say

56:59

P is a boolean and I have a statement P.

57:03

Can you assign some value of true or

57:05

false to P to make that true?

57:07

>> Typically you can assign true and it it

57:09

will correct

57:10

>> both true. Yeah.

57:11

>> So that statement is satisfiable by

57:12

setting P to true. What about P and not

57:14

Q

57:17

>> also satisfiable by by giving giving

57:20

true to P and false to Q.

57:22

>> Right. Now what about P and Q and not P?

57:27

that that unsatisfiable because no

57:29

matter what booleaning you do the the

57:32

true and false will always will never be

57:34

true.

57:34

>> Lovely. What you've just done is a

57:36

boolean satisfiability problem taken

57:38

some sort of statement of a ton of

57:39

boolean variables in this case two and

57:42

found some either found some assignment

57:43

that makes it true or said that it

57:45

cannot be made true. Now boolean

57:48

satisfiability is what we call empty and

57:50

what that means in theory is that

57:51

there's no such thing as a perfectly

57:53

efficient algorithm that solves all

57:55

problems. In practice that means that we

57:57

can solve them really fast. So often

58:01

what makes alloy interesting is that

58:03

unlike TA plus which mostly brute forced

58:05

alloy can be converted into a

58:10

satisfiability prop. I'll open this up

58:13

and it is able to turn that

58:17

model into a

58:20

boolean probability saying not x21 and

58:24

x96 and x15 or not x72

58:29

etc. And because of that most alloy

58:32

models can be checked in like a few

58:35

milliseconds or a second at most.

58:36

Whereas often for like a large TA plus

58:38

model, you have to basically churn it

58:40

overnight to go through all 100 million

58:42

states.

58:43

>> Can we talk about some other tools uh on

58:45

the I guess a table of someone looking

58:48

into formal verification?

58:49

>> Happily. So I don't have any more demos

58:52

on my PC right now, but I can talk about

58:54

a few of them. So a couple of the ones

58:57

that have been success plus is um the P

58:59

language

59:01

um which was invented by I think a

59:02

person at Microsoft research who was

59:04

then poached by Amazon as a way of

59:07

making a language that was more

59:08

accessible than TLA plus among other

59:10

things. So it basically looks like a set

59:12

of um state machines interacting state

59:14

machines that send messages to each

59:15

other almost like the actor model in

59:17

like Erlang or something like that.

59:18

>> Yep.

59:19

>> So there's that. There's also another

59:21

one in the same space as um Quint which

59:23

was basically people who were making a

59:24

different kind of model check for TA

59:26

plus and then realized they can make an

59:29

entire language that was easier for

59:31

people to pick up. They've gotten a lot

59:32

of interest in the banking and um I

59:35

believe cryptocurrency space smart

59:37

contracts. So another one that I've used

59:39

which is which is a lot more niche but

59:41

quite interesting is called Prism and

59:43

Prism is a proistic mile checker. So

59:45

like Kila Plus can tell you like this

59:47

bug will never happen or it could

59:49

happen. Prism can tell you this bug can

59:52

happen 10% of the time or it is a 25%

59:55

chance of happening if you shut down.

59:57

It's really cool but it's also much more

59:59

like academic in that there's a lot more

60:02

work required to actually translate

60:03

languages into Prism. If you're

60:05

interested in it, I've basically been

60:06

doing this like um have you heard of the

60:08

Jewish game Drrele?

60:10

>> No.

60:10

>> Okay. It's a game that you play on

60:11

Clanica where you spin a little top and

60:13

you get money. and I do not like the

60:15

game. And I have written a two-part

60:17

series using Prism to show how this game

60:19

is not fun by analyzing as a

60:21

mathematical thing.

60:23

>> Love it.

60:24

>> Those are I think some of the ones that

60:25

are like really popular. But there's

60:27

also

60:28

um I mean I could just keep listening.

60:30

There's like there's like event B which

60:32

is like been used I believe famously in

60:35

part of the Paris Metro system. Um

60:38

there's like MCRL2 which I think is come

60:41

comes from a Dutch university. Hum X

60:43

which is mostly used for like um robotic

60:45

control systems but I think that's

60:46

mostly academic. There's like new SMV

60:49

which I think NASA's used for a bunch of

60:51

stuff. I can keep going. Then of course

60:54

there's all the of course this is only

60:55

for specifying like abstract models of

60:58

systems. If you want to talk about

60:59

verifying code then you've got things

61:00

like Daphne which is basically something

61:03

that compiles to like net and lets you

61:05

basically write provable code. You've

61:07

got JML for Java check for like model

61:09

checking Java code. You've got like um

61:11

Primma C for like checking C. You've got

61:14

Ada Spark. You've got like and you've

61:17

got Ethereum provers like um Rock and

61:19

Lean and Isabelle. And I can keep going.

61:21

I

61:21

>> I wanted to ask

61:23

how does property based testing

61:27

relate to formal verification and and

61:29

before let's just like lay out what

61:31

property based testing is.

61:33

>> So let's go back to that entire thing

61:34

with max right max of a list. we can

61:36

define like the specification of max it

61:38

is in the list and for all elements of

61:41

the list it is the largest element of

61:42

that list right I actually have a demo

61:45

on my computer of doing that so let's

61:47

actually go into this so over here in

61:50

this file that I wrote for my book plug

61:54

I have a

61:59

I have basically three variants of max a

62:02

good version which just returns the max

62:03

of the list one that returns the max of

62:05

the first three and one that returns max

62:06

the absolute value.

62:07

>> Yep.

62:08

>> This below here is a property test. What

62:11

it does is it says given a list of

62:16

integers where each list has at least

62:18

one integer in it.

62:19

>> Yep.

62:20

>> The maximum value of that function

62:22

should be in the list and all other

62:25

values should be less than or equal to

62:26

it.

62:27

>> Yep. Clear.

62:28

>> So this basically a lot like our formal

62:30

verification spec, our formal

62:32

specification spec. The difference

62:33

between the formal methods that we do

62:35

and um property testing is that the

62:38

formal methods are ask are saying like

62:39

okay can we prove this for every

62:41

possible list and property testing is

62:44

well that's very very hard and as we

62:47

talked about very difficult to do in

62:49

practice can we instead generate a

62:51

thousand random lists and try all those

62:53

I have it set so that way it basically

62:55

has the invalid max max the first three

62:58

>> we should be getting errors or it should

63:00

catch some errors.

63:01

>> Mhm. Let's run it.

63:07

Let me just run it from the command

63:08

line. That's faster. Uh

63:13

um pi test uh test max.py.

63:19

This is an old machine I mostly bring on

63:21

for conferences because it's like easy

63:22

to just throw in something on here.

63:27

So

63:30

we see over here that it says that this

63:32

test failed on this line that for the

63:35

list 00001

63:38

it is not true that all the values are

63:41

greater than zero. This is because I

63:44

said our badmax only looks at the first

63:46

three values. So it found the max was

63:47

zero but here the actual max of the list

63:50

was one.

63:51

I broke this down to two subspects for a

63:53

part of the book where we have testing

63:55

that max is the largest element and also

63:58

that it's in the list. So that's why one

63:59

of the tests passes. Um I should note

64:01

though that um if I believe I run this

64:04

with a verbose what I'm trying to do for

64:08

this demo is um show that it actually

64:10

does not start with the um largest list.

64:12

It actually starts with a much smaller

64:15

with here we go. If I print

64:18

max, if I print

64:21

then I do it like this. I think

64:29

it tries a lot of edge cases first. So

64:33

it's basically trying huge list is

64:35

trying like tiny list is trying like

64:37

empty list etc. And once it has one that

64:40

fails, for example, this value,

64:43

it starts to shrink it. Finding the

64:45

minimally interesting example. And

64:46

that's why this lets us like find a bug.

64:49

Not just find a bug, but also find a bug

64:51

and present it in a way that is like

64:52

comprehensible for the average human

64:54

because I think that it found the

64:55

original bug with this list. And I do

64:57

not think that looking at this, I'm

64:58

going to know what the problem is.

64:59

That's basically property property based

65:01

testing in a nutshell. And as you can

65:03

see, it is less thorough than formal

65:04

verification, but it's a lot easier to

65:06

apply. So, it sounds like it can be a

65:08

nice middle ground in terms of getting

65:10

started with it

65:11

>> and probably just stopping with it

65:13

because I think that I love formal

65:15

methods, but I think it's a fairly niche

65:17

tool for most people and I think like

65:20

property based testing is in general

65:22

going to be useful for more people.

65:24

>> So, speaking of of verification in

65:27

general, today we have AI generating way

65:30

more code. We have data to prove this as

65:32

well, but also dayto-day I I I see it on

65:34

myself. I have AI generate a lot more of

65:36

my code. We're getting more code. C code

65:38

reviews are people are it's hard to pay

65:42

more attention to this. So there's a

65:44

growing number of people saying well

65:46

maybe we should somehow validate things

65:48

more and there's an idea that keeps

65:50

coming up maybe for more verification or

65:53

property based testing or some of these

65:54

things could be more useful. Do you

65:56

think this will happen or because I see

66:00

a lot of people talking about this. I I

66:01

don't really see anyone doing much about

66:03

it. I'm definitely seeing more business

66:06

from people in my my client as method is

66:09

people trying to generate specs with AI

66:12

and then getting me to help like work

66:14

with the spec or like find issues with

66:15

that and I'm definitely seeing more

66:17

people like using property based

66:19

testing. I know for example I think Kro

66:21

like the Amazon specri development

66:23

platform specifically advertises

66:25

generating property tests as like one of

66:27

the key values of it and I've been

66:29

seeing a lot of like papers about

66:30

generating specs using AI. I will say

66:34

this is kind of really exciting because

66:36

as you saw like a lot of the challenge

66:37

of writing a spec not all of it but like

66:38

a lot of it is like rocking your head

66:40

around like very very technical syntax

66:43

and like semantics.

66:47

That said, I've been doing a lot of

66:49

experience with this myself and I think

66:50

the one thing AI is extremely bad at as

66:53

of March, I know that claude just

66:55

released a new like cloud 4.8, so maybe

66:57

this is all out the window. It changes

66:58

every month. It is very bad at coming up

67:01

with properties. It is very bad at that.

67:04

>> What What does coming up with properties

67:06

mean? Is it writing the actual form of

67:08

verification part?

67:09

>> Yes. So, like if you give it properties

67:10

and like a spec, it can tell you like,

67:12

hey, we're going to fix the spec, make

67:13

these properties pass. That's fine. What

67:16

if you basically tell it here's a spec

67:17

also come up with the properties of the

67:18

spec. It'll be like, okay, so one of the

67:20

properties I'm going to specify is that

67:23

either P is true or not P is true. And

67:25

then you're like, that's just always

67:26

true. And it's like, wow, I verified it.

67:27

Amazing. I'm so good at this. Especially

67:29

when you deal with what's called

67:30

livveness properties, properties about

67:31

how like a system can evolve over a long

67:33

period of time. It just it's hard to put

67:37

down. It's just not good at that yet.

67:39

And often I found with my clients, I

67:41

have to tell them like it's doing a good

67:43

job at generating the actual design, but

67:45

in actually expressing what the design

67:46

is supposed to do, it cannot do that

67:48

yet. You have to do that part yourself.

67:50

>> It's interesting because there's a

67:51

there's a blog post that I'll also link

67:52

in the show notes uh from a year ago in

67:55

March 2025 titled the coming revolution

67:57

in distributed systems. And this was an

67:59

engineer working on GitHub's copilot

68:01

team. And this person wrote how uh AI

68:04

autonomously produced precise TLA plus

68:06

specifications from Azure storage

68:08

production source code and it uncovered

68:10

a subal race condition uh that had

68:12

debated traditional code reviews. And

68:14

then this person was very enthusiastic

68:16

and saying well this could be a

68:17

revolution AI could just generate TA

68:20

plus from specification like it did with

68:22

Azure. This was a year ago and I haven't

68:24

heard much on any of this even though

68:27

the models were not as great. What have

68:29

you seen in in this area? So actually

68:31

the same person Chang Huang um did come

68:33

up with a um tool called Lampport agent

68:35

where they demonstrated using this to um

68:38

specify parts of um crack I think it's

68:40

called part of DC's crack. Um I'm going

68:42

to link both those in the thing. Here's

68:45

my response because I was writing about

68:46

this and then the thing that they did.

68:48

He seemed to do have be a lot more

68:50

successful than than um I was at

68:52

generating properties. But um one at

68:54

least the example that he showcased in

68:57

his like later piece one he's an expert

68:59

specifier who like already knows how to

69:00

do this stuff on his own without the LM

69:02

so that makes it easier yeah he knows

69:03

how to like get good results out of it

69:05

>> as that's a general thing we've seen

69:06

like to get good results you have to

69:07

already know how to get good results

69:08

without it just helps you get good

69:10

results faster and also he one of the

69:12

systems that he was able to create the

69:14

complicated properties for in TA plus

69:16

already had a sophisticated spec written

69:18

in P so I don't know how much that's

69:20

relevant here maybe it read that and it

69:22

cheated Maybe that was like fine. I

69:24

don't know.

69:25

>> But we we do see this a lot where when

69:26

you're an expert in a domain and may

69:28

that be software engineering or or like

69:30

backend or mobile AI works better for

69:32

you. Then there's also this one

69:34

interesting um person um Claudia Collie

69:36

did write a write up because she just

69:37

did about a multi-year project in using

69:40

methods at um the big Chinese cloud

69:41

provider where she talks about how in

69:44

between her like working on this paper

69:47

and

69:49

like the time she got published she got

69:51

really sophisticated on how long it took

69:53

people to write formal methods at this

69:55

one company and then LM's basically just

69:57

compressed the scale by the time she

69:58

actually had the paper out. So I think

70:00

people are seeing like more use from

70:02

like for methods but it seems people

70:03

with the most success right now are

70:05

specifiers who are using it to amplify

70:07

their ability to specify and we haven't

70:09

yet really seen I mean people post

70:11

hacker news all the time like people who

70:13

they had a AI write the whole spec for

70:15

them but those tend to not be very good

70:16

specs and and what's your take on again

70:19

I've heard some voices say that AI might

70:21

make formal verification go mainstream

70:24

off based on this but but outside of the

70:26

do you see any movement outside of the

70:29

this niche of people who already know

70:30

how to do formal verification.

70:32

>> I think it is making it more popular. I

70:33

don't know if it'll make it go

70:34

mainstream, but it's definitely making

70:35

it a lot more popular. It's bringing it

70:37

from maybe like.1% to.3%.

70:40

Which is huge.

70:41

>> There's also this uh this thinking that

70:44

I I' I've read actually in in in June

70:47

2025 in your newsletter, you said that

70:49

AI is a specification force multiplier.

70:52

And now, of course, we see that LM are

70:54

are bad at vibing specifications.

70:58

What changed between that time where

71:00

where you saw that they were like a year

71:02

ago they were pretty decent at at doing

71:03

it or they had science and now we have

71:06

bit more proof they're not as good.

71:08

>> So what I wrote that it was really good

71:09

at was fixing syntax errors which is

71:10

really big because um that's often trips

71:13

people up. It's good at understanding

71:14

error traces which is huge because being

71:15

able to take like a 35step error trace

71:17

and turn that into like two paragraphs

71:19

of English text major improvement. good

71:22

at boiler plate like mass changes to

71:23

like a bunch of small things like

71:25

updating like boiler plate and

71:29

it's okay at writing properties from a

71:33

very precise description. It's bad at

71:35

fixing specs and it's real bad at

71:37

providing properties for a spec. Ha, I'm

71:38

still consistent.

71:39

>> Yeah.

71:39

>> So, I think I call that early back then

71:41

that it like is really bad. It's good at

71:44

translating properties from like

71:45

English, precise English into a spec,

71:46

but it's bad at coming up with

71:48

properties on its own. everything I got

71:49

back was trivial. I understand you're

71:50

too cold with the implementation

71:51

details. So I think ultimately what I'm

71:53

going to say is that like I think it has

71:55

a lot of potential to improve things,

71:56

but even back then in 2025

71:59

I was noticing that it was really bad at

72:00

this one thing that it continues it

72:02

continued to be bad as of March of this

72:04

year.

72:05

>> So then how much do you think you really

72:07

need to know formal methods to be able

72:09

to use LLMs to help you at all? You need

72:11

to get the basics in place likely.

72:14

>> I think getting the basics in place is

72:15

really valuable here, right? Because for

72:17

one, I mean, even discounting like being

72:20

able to like write the properties and

72:21

all that, you need to be able to tell

72:22

when the AI is doing something wrong,

72:24

right? And if you don't know the basics,

72:26

you can't really do that very well.

72:27

>> In your book, Logic for Programmers, you

72:30

argue that formal logic is probably one

72:32

of the most useful parts for for

72:36

day-to-day engineering.

72:38

Why? Why is this?

72:39

>> First of all, I'm honored that you've

72:40

read my book, or at least the early

72:41

drafts. I mean the official answer is

72:43

because logic teaches us to work with

72:45

like booleans and statements what we

72:48

learn in elementary school how to work

72:50

with numbers right essentially there's

72:52

not a whole lot of difference between

72:53

knowing that 1 plus 1 is two and true

72:57

and true is true it's still the

72:59

manipulation of values and it happens

73:00

that booleans are so important to

73:02

software engineering that having some

73:05

formal grounding in that is very handy

73:07

especially when we are not taught that

73:09

in school for the most part the other

73:11

answer is that I've just on learning

73:14

logic and getting better at logic and

73:15

teaching logic a lot as part of teaching

73:17

TA plus I just finding more and more

73:19

applications where I'm like oh because

73:21

of logic I can do this one thing and I

73:23

find that people who don't have that

73:25

background struggle to do that one thing

73:27

I guess I'm saying that empirically

73:28

logic keeps coming up as a useful form

73:31

of math

73:31

>> and if I'm a software engineer and I

73:33

work on complicated systems distributed

73:35

systems what techniques would you

73:37

recommend that I look into to harden

73:39

these systems we can assume that I'm

73:41

already doing basic unit testing,

73:43

potentially integration testing, but I'm

73:45

now interested in like, well, should I

73:47

look into formal methods, property based

73:49

testing? If it's formal methods, there's

73:51

all these different technologies. It's

73:53

it's it's almost overwhelming. What what

73:55

is a good good place to to start to just

73:58

do some experiments that are cheap to

74:00

do?

74:00

>> I'm going to just completely go 90° here

74:03

and um recommend this book by um Nancy

74:04

Leon called Engineering a Safer World.

74:07

Um she was an aeronautics engineer who

74:10

investigated things like the 25

74:12

radiation case and like the Colombia

74:14

disaster and she was really fascinated

74:17

in how like systems have been accidents

74:21

and systems happen like why accidents

74:22

could happen in complicated systems and

74:25

I found her writing on this to be

74:27

incredibly insightful and incredibly

74:28

valuable in understanding how these

74:30

systems can break. So that's the thing

74:32

at first I'd recommend is checking out

74:33

that book. looking ahead for for the

74:35

industry a year ago. You wrote a post

74:36

where you shared some of the

74:38

uncertainties and anxieties. It was a

74:41

longer post. Uh it started with how VIP

74:43

coding will be never good as software

74:44

engineering experienced software

74:45

engineers and you wrote six different

74:47

things. Can we read through them and and

74:49

just reflect on how you feel about them?

74:52

What you think might have changed and

74:54

and maybe talk about what potential new

74:55

anxieties we have because there's so

74:57

much change going on. That's for sure.

74:58

>> The way I sort of think about it is that

74:59

the next five years keep being rewritten

75:01

every few months,

75:02

>> right?

75:02

>> Yeah. So I wrote the following can all

75:04

be true. One, bibec coders will never be

75:06

good at software engineering as an

75:08

experienced software engineer. Probably

75:09

true. I mean, if you don't have the

75:11

basics, you can't really

75:12

>> It feels true. I I I even see it on

75:14

myself when I try to build a software in

75:16

a domain I'm not an expert in, like a

75:18

game, and it's an absolute just vibe

75:21

coded mess.

75:21

>> Yeah, LMS can significantly augment a

75:24

sign a professional software engineer's

75:26

ability to quickly write high quality

75:27

software. I think also true. I mean,

75:30

even if you don't have it writing a

75:31

single line of code, just being able to

75:32

be like, okay, what's this bug? Where's

75:33

the bug? Or like, hey, what library

75:36

should I look into to solve this

75:37

problem? And we're I think we're

75:39

starting to see or starting to recognize

75:40

that engineers who have really deep

75:43

knowledge are so much more efficient.

75:45

And the ones who embrace these tools and

75:48

figure out how to control them and not

75:49

them to control, you know, like like

75:51

their anxiety or whatnot, they get a lot

75:53

done.

75:54

>> Absolutely. Elements will cause many

75:56

software developers to lose their jobs.

75:58

I don't know. That's a hard one to pin

75:59

down because like I mean one the

76:01

software engineering at least in the US

76:03

is starting to recover. Like we're

76:04

starting to see more jobs open up for

76:05

software development. So it's hard to

76:07

tell how much of like the loss of the

76:09

past few years was AI versus the end of

76:12

like zero interest rate policy and like

76:14

the postcoid crash. And I think it's

76:17

more the latter but like again LM are

76:19

still getting better. Maybe they're

76:20

going to cause job losses in the future.

76:22

>> Yeah, this is a noble question. the data

76:24

that we had in the pragmatic engineer it

76:26

did show that we are seeing overall more

76:28

software engineering openings in the US

76:30

in Germany and France they're declining

76:32

a little bit at the same time and there

76:34

seems to be a big shift on who is being

76:36

hired and the skill set so now AI

76:38

engineering is increasingly spreading to

76:41

more software engineering fields not all

76:43

of them and we're seeing a decrease in

76:44

for example front-end engineering hiring

76:46

mobile engineering hiring so I think the

76:47

shape is changing but it's always

76:49

changed in the past if you think about

76:50

20 years ago the most in demand engineer

76:53

was a Java engineer like Java

76:55

specifically like don't care 10 years of

76:57

Java experience required and that's

76:59

changed

77:00

>> okay then we'll open up new jobs for

77:02

many possibly far many software

77:03

developers I think that's also true I

77:05

think when you basically need one

77:07

developer to make your product as

77:08

opposed to five you're looking to hire

77:10

one developer right

77:11

>> that's been true yeah y

77:12

>> the software jobs that LLM open up will

77:15

be lower paid to lower precision the

77:16

heights of the 2008 to22 tech era and

77:18

that's the thing that scares me the most

77:19

is that as mentioned I decided to leave

77:23

a field and just become a techie. And I

77:24

was able to do that. And I was able to

77:26

get a well-paying job that led to me to

77:29

now full-time mathematically prove

77:31

systems correct. That's crazy. What

77:33

other field can somebody just go like

77:34

what other engineering field like I want

77:36

to be an engineer and just walk straight

77:37

into it? What other field is going to

77:38

send people to Budapest from the US to

77:41

give a talk for 45 minutes? Like it is

77:44

really precious and magical what we have

77:46

here and I'm afraid of losing that. I'm

77:49

afraid of a place where it just becomes

77:51

like any other like white collar job

77:54

where you get two weeks paid vacation

77:56

every year and like two days off sick

77:58

and I don't want to lose that.

78:00

>> Are we saying we're afraid that software

78:02

engineering might become just like every

78:04

other engineering job? Yes.

78:06

>> Because that is the reality of a lot of

78:08

engineering jobs. We do have a

78:09

privilege. I I don't think we talked

78:10

about it when we compared with the rest

78:12

of engineering. We have massive

78:13

privilege.

78:13

>> Yes. We have a huge amount of privilege

78:15

and I don't want to lose that and I I

78:16

mean it would be nice if everybody else

78:17

got the same things we are but I don't

78:19

want to like equalize us by losing what

78:21

makes software engineering so magical

78:24

and precious.

78:25

>> Yeah. So this is a worry.

78:26

>> Yeah. That's my that's my fear.

78:27

>> And then number six

78:29

>> there will be still be high paid

78:30

professional software engineering jobs

78:31

but they will be rare, more competitive

78:33

and more and less developer friendly.

78:35

>> I'm afraid we're seeing some of this

78:36

already. I I wonder if this is

78:39

inevitable. Um I also see it in some

78:41

other industries. For example, with

78:42

investment banking, uh the the traders

78:45

used to be many of them very highly

78:47

paid, highly respected. There are now

78:49

fewer of them still highly paid, highly

78:51

respected. It's harder to get into them.

78:53

>> Yeah. I mean, I think I think like most

78:54

jobs do oify over time like as like the

78:57

standards are set and more people enter

78:58

them. Um sovereignty I think for a

79:01

longer period of time was able to like

79:03

get away from that.

79:05

>> Yeah. And then and and then you closed

79:06

your prediction uh with with with these

79:08

lines a year ago.

79:09

>> I predict that in the next 10 years

79:10

software development will survive, but

79:12

it will become like any other white

79:14

collar professional work. No more

79:15

$200,000 salaries, a lunification, or

79:17

incredible employee bargaining power. I

79:20

feel sad that we'll lose something so

79:21

magical, but I guess it couldn't have

79:22

last forever. Automation comes for all

79:24

of us, even us automators. Here's a

79:26

crazy way of ending this actually fits

79:28

in the backling. If we start with

79:29

automation comes for all of us, even

79:30

automators. And like on one hand, I feel

79:32

like I'm losing something really

79:32

special. On the other hand, a doctor

79:34

friend of mine came to me like a few

79:36

months back and was like, "Hey, we

79:37

managed to like create a new shift

79:39

scheduling platform for like our

79:40

hospital like to trade shifts that

79:42

really saved us all a lot of time and

79:44

like made all of us nurses and doctors

79:45

so much happier." And I was able to just

79:47

vibe it out. I don't know any kind of

79:48

code, but like AI let me do this. And

79:50

I'm like, "Wow, it really is helping you

79:52

like in your hospital make your life

79:54

better." And it's like it it feels so

79:56

weird to balance my needs as a

79:59

professional software developer with

80:00

like his needs as a doctor. Like who

80:02

matters more? like my cushy job or his

80:04

job. Like I I don't know. And it's going

80:06

to we're going to all find this out in

80:07

the next 10 years. I guess

80:09

>> Grady Woo told me that this time reminds

80:11

him of the time in the 19 late 1960s and

80:14

early 1970s where people could purchase

80:17

computers and start to hack with them.

80:19

And he said it was a magical time

80:21

because teachers and people who had

80:22

nothing to do with software saved up and

80:25

start to just hack around and it

80:28

democratized it. And I feel this is the

80:30

first time I'm also feeling like this

80:32

other person in the gym told me that

80:34

they're vibing something together. It

80:35

feels it's opening up the field and if

80:38

anything a lot more people are

80:39

realizing, oh software is cool. I can do

80:41

it and now they're starting to learn the

80:42

hard parts of software engineering

80:44

eventually.

80:44

>> Did you ever read up Clay Sher's essay

80:46

situated software?

80:47

>> No. Basically what it is is that this

80:49

person was talking about

80:51

um how they think like the most

80:56

important the vast majority of software

80:57

should be made for like three people or

80:59

like a family or community or like one

81:02

school. And up until now that like could

81:05

only really happen if one of those

81:06

people in that family that community

81:07

that school was like really really into

81:09

computers. But now it's possible for

81:11

everybody to have situated software and

81:14

that again is going to change the world

81:16

in some strange and some terrifying and

81:19

some exciting ways.

81:20

>> It's exciting. As closing, what are

81:22

books, a few books that you could

81:24

recommend that you have enjoyed or made

81:26

an impact on you?

81:27

>> Oh boy. Let's just leave this just for

81:29

this into just software books, okay?

81:31

Because otherwise we're going to be here

81:32

for like a month. So there's three books

81:34

that I really love in software that I

81:35

think of as like the books that have

81:36

influenced me so much. The first one I

81:39

think I mentioned in the interview was

81:41

um Nancy Leonson's Engineering a Safer

81:42

World. I believe that's actually free

81:44

online. The second book is called Data

81:46

and Reality by um Bill Kent. And this

81:49

one's actually hard to find because it

81:51

was republished in 200 I think 11, but

81:53

the republisher changed the book. So the

81:56

last good edition is is the second

81:57

edition which can be found like in dark

81:59

corners of the internet online is

82:00

actually kind of hard but like it is

82:02

basically by this like famous database

82:04

designer who like worked on like IBM

82:06

databases who was just asking like what

82:08

is data? What does it mean for something

82:10

to have identity? What does it mean for

82:11

something to have oneness? If we talk

82:12

about a book is that the book the

82:14

physical copy is that the series is that

82:17

an addition? And it's just an entire

82:19

book about these questions about what

82:21

data is and how we need to represent it.

82:23

He ends it by saying that data isn't

82:25

reality. It is our view of reality for

82:27

our useful purpose. Incredible book. It

82:30

totally changed how I think about

82:32

things. The last book is um called

82:35

debugging the nine simple rules by David

82:38

Aens. And it's literally just like a

82:40

book of war stories about debugging and

82:42

like basic principles. But this is the

82:45

book I give to every junior engineer

82:46

because I think like nobody ever really

82:49

talks about debugging as like a

82:51

discipline outside of like basic

82:52

heristics. this is like just at least

82:54

something that's trying to do that and

82:56

having something is better than nothing

82:57

in this category. So really good book

82:59

and I think it's like $10 for a used

83:01

copy. So like anybody can just get one.

83:02

It's great. Those I think are the three

83:04

most useful books for software

83:05

engineers. If you want to talk about

83:06

other books I can keep going but

83:08

[laughter]

83:09

this this is great. Well hello this was

83:12

very educational

83:14

and I found it fascinating. Thank you.

83:16

Thank you. I really enjoyed this

83:18

conversation, especially the demos where

83:20

Hill showed tools like [music] TA+ alloy

83:22

or hypothesis and how they can catch

83:24

bugs. By the end of the conversation,

83:26

I'm starting to understand more why it's

83:28

not likely that formal verification will

83:30

go mainstream even with AI. I mean,

83:32

these tools feel very rigid for the real

83:34

world. For specific parts of a system

83:36

that you can model mathematically, like

83:38

state spaces, sure, they can work, but

83:41

for everyday programs, it just feels

83:42

like it would be a bit pointless to

83:44

create TA plus specifications.

83:47

One thing that I was also thinking about

83:49

is how Hill talked about why he thinks

83:51

we're not good at catching concurrency

83:53

bugs, and it's because we don't have

83:54

much practice with them. [music] As a

83:56

developer, you're lucky to debug a

83:58

concurrency bug once every few years.

84:00

So, of course, you won't be able to

84:02

build expertise [music] this way. This

84:04

is also similar to how most engineers

84:05

are bad at migrations because most devs

84:07

only ever do one or two migrations over

84:09

several years. But if you're an engineer

84:11

who does a bunch of migrations, you're

84:13

going to be really good at them. Same

84:14

thing if you're working on systems with

84:16

concurrency issues and you become an

84:18

expert in this. I also find it

84:20

fascinating how other engineering fields

84:21

have similarities with software

84:23

engineering, like how mining engineers

84:24

had their own agile revolution in the

84:26

1960s and how all engineers hate the

84:28

concept of waterfall. [music] Plus, it

84:30

was amusing to hear how source control

84:31

is kind of an envy from other

84:33

engineering fields that we software

84:34

engineers have, but not many others do.

84:37

Check out the show notes for related

84:38

deep dives on distributed systems at

84:39

TechDEP that go into more detail into

84:41

the topics that we talked about today.

84:43

And if you've enjoyed this podcast,

84:45

please do subscribe on your favorite

84:46

podcast platform and on YouTube. A

84:48

special thank you if you also leave a

84:49

rating on the show. Thanks and see you

84:52

in the next

Interactive Summary

This video features Hill Wayne, a formal methods consultant, discussing the application and future of formal methods in software engineering, especially in the era of AI. He explains formal methods as making implicit knowledge about a function explicit and using mathematical proofs to ensure correctness for all possible inputs. While not practical for all problems due to complexity, formal methods are crucial for critical systems, with AWS famously using TLA+ to uncover data loss bugs in DynamoDB and S3. Wayne's "Crossover Project" explored whether software engineers are "real" engineers, concluding they are, sharing many similarities with traditional engineers (e.g., all hate waterfall, value iteration) while also having unique advantages like faster iteration, open-source culture, and advanced version control. Software engineers could learn better planning and compiling specific domain knowledge from traditional fields. The discussion also covers various formal methods tools like TLA+, Alloy, P, Quint, and Prism, as well as property-based testing as a more lightweight alternative. Hill notes that while AI can assist in fixing syntax, understanding error traces, and translating precise English into specifications, it currently struggles to autonomously generate meaningful properties for formal verification. A significant anxiety expressed is the potential loss of software engineering's "magical" aspects, such as high salaries and unique benefits, fearing it may become just another white-collar job due to increased automation and competition.

Suggested questions

10 ready-made prompts