Menu
Sign In Search Podcasts Libraries Charts People & Topics Add Podcast API Blog Pricing

Martin Kleppmann

๐Ÿ‘ค Speaker
607 total appearances

Appearances Over Time

Podcast Appearances

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

It takes a long time to

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

learn the language of writing those proofs.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

And then even once you know the language, it's just really laborious in order to actually write the individual proof steps.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

Yeah, so you're trying to make a proof that a certain piece of code always satisfies a certain property.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

In some cases, that property might be quite easy to specify.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

Let's say as a really simple example, you have two lists and you want to concatenate them.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

And then you want to prove that the length of the concatenated list equals the sum of the two individual lists.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

Very, very simple property.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

How would you prove something like this?

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

Well, you would have a function that concatenates two lists, and then you would probably do a proof by induction over one of the lists that shows that, okay, well, if you have one list of length i and another list of length 0, well, then the sum of the two is i. If you have a list of length i appended with a list of length 1,

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

well, then it's i plus 1 and so on.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

And then by using a proof by induction, you can then show that the length of the concatenated list is i plus j, where i and j are the lengths of the two input lists for every possible value of i and j. And this is something that, you know, in a test case, you would, in tests, you would maybe test it for the cases of j equals 0, j equals 1, and j equals 5, and then you're done.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

And j equals interior max.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

Yes.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

In the edge case, if that's what we do, that's how I write my unit test.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

Exactly.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

And so this is a trivial example, like list concatenation.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

You can easily just read the code and convince yourself that it's correct.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

But if it's a much more complex algorithm, then our brains just can't like grok the algorithm well enough to really convince ourselves that it's correct if you don't prove it.

The Pragmatic Engineer
Designing Data-intensive Applications with Martin Kleppmann

And that's where these proofs then become handy.