DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to...

320
TLA + Video Course – Lecture 4 Leslie Lamport DIE HARD This video should be viewed in conjunction with a Web page. To find that page, search the Web for TLA+ Video Course . The TLA + Video Course Lecture 4 Die Hard

Transcript of DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to...

Page 1: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLA+ Video Course – Lecture 4Leslie Lamport

DIE HARD

This video should be viewed in conjunction with a Web page.To find that page, search the Web for TLA+ Video Course .

The TLA+ Video CourseLecture 4Die Hard

Page 2: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In this video, you’ll learn how TLC can save your life. . . if you ever findyourself in the middle of a Hollywood action movie.

This will require you to learn some more about TLA+, TLC, and the Toolbox— which could turn out to be useful even outside of Hollywood.

[ slide 2 ]

Page 3: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

THE DIE HARD PROBLEM

[ slide 3 ]

Page 4: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

Die Hard 3 is a 1995 action film starring Bruce Willis and Samuel L. Jacksonas the heroes.

To disarm a bomb, they had to put exactly 4 gallons of water in a jug.

[ slide 4 ]

Page 5: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

Die Hard 3 is a 1995 action film starring Bruce Willis and Samuel L. Jacksonas the heroes.

To disarm a bomb, they had to put exactly 4 gallons of water in a jug.

[ slide 5 ]

Page 6: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

Die Hard 3 is a 1995 action film starring Bruce Willis and Samuel L. Jacksonas the heroes.

To disarm a bomb, they had to put exactly 4 gallons of water in a jug.

[ slide 6 ]

Page 7: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

1 U.S. gallon = 164 hogshead

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

Die Hard 3 is a 1995 action film starring Bruce Willis and Samuel L. Jacksonas the heroes.

To disarm a bomb, they had to put exactly 4 gallons of water in a jug.

[ slide 7 ]

Page 8: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

1 U.S. gallon = 164 hogshead = 3.785411784 liters

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

Die Hard 3 is a 1995 action film starring Bruce Willis and Samuel L. Jacksonas the heroes.

To disarm a bomb, they had to put exactly 4 gallons of water in a jug.

[ slide 8 ]

Page 9: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

They were given a 3 gallon jug, a 5 gallon jug, and a water faucet.

You can watch the relevant scene by searching the Web for Die Hard JugsProblem YouTube.

[ slide 9 ]

Page 10: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Die Hard 3

A 1995 action film.

The heroes had to put exactly 4 gallons ofwater in a jug.

They had a 3 gallon jug, a 5 gallon jug, and a water faucet.

Search the Web for: Die Hard Jugs Problem YouTube.

They were given a 3 gallon jug, a 5 gallon jug, and a water faucet.

You can watch the relevant scene by searching the Web for Die Hard JugsProblem YouTube.

[ slide 10 ]

Page 11: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There were no markings on the jugs.

They needed exacty 4 gallons.

Not 3.99 or 4.01.

There were no markings on the jugs.

They needed exacty 4 gallons.

Not 3.99 or 4.01 gallons.

[ slide 11 ]

Page 12: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There were no markings on the jugs.

They needed exacty 4 gallons.

Not 3.99 or 4.01.

There were no markings on the jugs.

They needed exacty 4 gallons.

Not 3.99 or 4.01 gallons.

[ slide 12 ]

Page 13: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There were no markings on the jugs.

They needed exacty 4 gallons.

Not 3.99 or 4.01.

There were no markings on the jugs.

They needed exacty 4 gallons.

Not 3.99 or 4.01 gallons.

[ slide 13 ]

Page 14: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

GETTING STARTED

[ slide 14 ]

Page 15: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Getting Started on a Spec

The best way:

Write a single correct behavior.

Informally.

When we want to write a spec, what should we do first?

I recommend writing the start of a single correct behavior.

Informally at first.

[ slide 15 ]

Page 16: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Getting Started on a Spec

The best way:

Write a single correct behavior.

Informally.

When we want to write a spec, what should we do first?

I recommend writing the start of a single correct behavior.

Informally at first.

[ slide 16 ]

Page 17: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Getting Started on a Spec

The best way:

Write a single correct behavior.

Informally.

When we want to write a spec, what should we do first?

I recommend writing the start of a single correct behavior.

Informally at first.

[ slide 17 ]

Page 18: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This isn’t a big budget movie.

I’ll use these cartoon jugs:

This isn’t a big budget Hollywood movie, and I can’t affort big jugs.

So instead, I’ll illustrate the spec with these cartoon jugs.

[ slide 18 ]

Page 19: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This isn’t a big budget movie.

I’ll use these cartoon jugs:

This isn’t a big budget Hollywood movie, and I can’t affort big jugs.

So instead, I’ll illustrate the spec with these cartoon jugs.

[ slide 19 ]

Page 20: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

They start with both jugs empty.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 20 ]

Page 21: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 21 ]

Page 22: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 22 ]

Page 23: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 23 ]

Page 24: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 24 ]

Page 25: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 25 ]

Page 26: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 26 ]

Page 27: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

It’s possible for them topour 4 gallons of waterinto the 5-gallon jug.

But they’d have to be very luckyto get exactly 4 gallons.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 27 ]

Page 28: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

We only allow behaviors wherethey know exactly how muchwater is in each jug.

Our heroes start with both jugs empty.

It’s possible for them to solve their problem by simply pouring 4 gallons ofwater into the 5-gallon jug.

But they’d have to be very lucky to get exactly 4 gallons.

So we only allow behaviors in which they always know exactly how muchwater is in each jug.

[ slide 28 ]

Page 29: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Initially, both jugs empty.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 29 ]

Page 30: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 30 ]

Page 31: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 31 ]

Page 32: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 32 ]

Page 33: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 33 ]

Page 34: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 34 ]

Page 35: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty 3-gal. jug into 5-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 35 ]

Page 36: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty 3-gal. jug into 5-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 36 ]

Page 37: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty 3-gal. jug into 5-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 37 ]

Page 38: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty 3-gal. jug into 5-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 38 ]

Page 39: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty 3-gal. jug into 5-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 39 ]

Page 40: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ →

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 40 ]

Page 41: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ →

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 41 ]

Page 42: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ →

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 42 ]

Page 43: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ →

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 43 ]

Page 44: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ →

Fill 3-gal. jug.

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 44 ]

Page 45: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → →

Again, they start with both jugs empty.

The only thing they can do now is fill a jug. Suppose they fill the 3 gallon jug.

Next, they empty the water from the 3 gallon jug into the 5 gallon jug.

Now they fill the 3 gallon jug.

[ slide 45 ]

Page 46: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → →

Fill 5-gal. jug from 3-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 46 ]

Page 47: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → →

Fill 5-gal. jug from 3-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 47 ]

Page 48: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → →

Fill 5-gal. jug from 3-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 48 ]

Page 49: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → →

Fill 5-gal. jug from 3-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 49 ]

Page 50: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → →

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 50 ]

Page 51: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → →

Empty 5-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 51 ]

Page 52: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → →

Empty 5-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 52 ]

Page 53: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → →

Empty 5-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 53 ]

Page 54: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → →

Empty 5-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 54 ]

Page 55: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → →

Empty 5-gal. jug.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 55 ]

Page 56: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → → →

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 56 ]

Page 57: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

→ → → → → → · · ·

And so on.

Now they fill the 5 gallon jug from the 3 gallon jug.

They then empty the 5-gallon jug onto the ground.

And so on.

[ slide 57 ]

Page 58: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This is just one possible behavior.

Let’s write it more formally.

Let values of small and big representnumber of gallons in each jug.

→ → → → → → · · ·

This is just one of many possible ways a behavior can begin.

Let’s write it more formally.

Let the values of the variables small and big represent the number of gallonsof water in each jug.

[ slide 58 ]

Page 59: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This is just one possible behavior.

Let’s write it more formally.

Let values of small and big representnumber of gallons in each jug.

→ → → → → → · · ·

This is just one of many possible ways a behavior can begin.

Let’s write it more formally.

Let the values of the variables small and big represent the number of gallonsof water in each jug.

[ slide 59 ]

Page 60: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This is just one possible behavior.

Let’s write it more formally.

Let values of small and big representnumber of gallons in each jug.

→ → → → → → · · ·

This is just one of many possible ways a behavior can begin.

Let’s write it more formally.

Let the values of the variables small and big represent the number of gallonsof water in each jug.

[ slide 60 ]

Page 61: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 0

]

→ → → → → → · · ·

Initially, both jugs have 0 gallons of water.

Filling the small jug puts 3 gallons of water in it.

Those 3 gallons are transferred from the small jug to the big jug.

[ slide 61 ]

Page 62: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill small jug.

[small : 0big : 0

] [small : 3big : 0

]

→ → → → → → · · ·

Initially, both jugs have 0 gallons of water.

Filling the small jug puts 3 gallons of water in it.

Those 3 gallons are transferred from the small jug to the big jug.

[ slide 62 ]

Page 63: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty small juginto big jug.[

small : 0big : 0

] [small : 3big : 0

] [small : 0big : 3

]

→ → → → → → · · ·

Initially, both jugs have 0 gallons of water.

Filling the small jug puts 3 gallons of water in it.

Those 3 gallons are transferred from the small jug to the big jug.

[ slide 63 ]

Page 64: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill small jug.

[small : 0big : 0

] [small : 3big : 0

] [small : 0big : 3

] [small : 3big : 3

]

→ → → → → → · · ·

3 gallons are then added to the small jug.

The big jug is then filled from the small jug, putting 5 gallons in the big jugand leaving 1 gallon in the small jug.

The big jug is then emptied, leaving 0 gallons in it.

[ slide 64 ]

Page 65: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill big jugfrom small jug.[

small : 0big : 0

] [small : 3big : 0

] [small : 0big : 3

] [small : 3big : 3

] [small : 1big : 5

]

→ → → → → → · · ·

3 gallons are then added to the small jug.

The big jug is then filled from the small jug, putting 5 gallons in the big jugand leaving 1 gallon in the small jug.

The big jug is then emptied, leaving 0 gallons in it.

[ slide 65 ]

Page 66: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Empty big jug.

[small : 0big : 0

] [small : 3big : 0

] [small : 0big : 3

] [small : 3big : 3

] [small : 1big : 5

] [small : 1big : 0

]

→ → → → → → · · ·

3 gallons are then added to the small jug.

The big jug is then filled from the small jug, putting 5 gallons in the big jugand leaving 1 gallon in the small jug.

The big jug is then emptied, leaving 0 gallons in it.

[ slide 66 ]

Page 67: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 0

] [small : 3big : 0

] [small : 0big : 3

] [small : 3big : 3

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → → · · ·

3 gallons are then added to the small jug.

The big jug is then filled from the small jug, putting 5 gallons in the big jugand leaving 1 gallon in the small jug.

The big jug is then emptied, leaving 0 gallons in it.

[ slide 67 ]

Page 68: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

What did we learn from this behavior?

1. What the variables are.

2. What constitutes a step.

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

What did we learn by writing this behavior?We learned two things.

First, what the variables are.

And second, what constitutes a step. For example. . .

[ slide 68 ]

Page 69: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

What did we learn from this behavior?

1. What the variables are.

2. What constitutes a step.

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

What did we learn by writing this behavior?We learned two things.

First, what the variables are.

And second, what constitutes a step. For example. . .

[ slide 69 ]

Page 70: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

What did we learn from this behavior?

1. What the variables are.

2. What constitutes a step.

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

What did we learn by writing this behavior?We learned two things.

First, what the variables are.

And second, what constitutes a step. For example. . .

[ slide 70 ]

Page 71: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

1. What the variables are.

2. What constitutes a step.

Filling a jug is a single step.

No intermediate states.[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

Filling a jug is a single step.

There’s no intermediate partially-filled state or states.

This is the simplest abstraction of the behavior of real jugs and water forthe particular problem faced by our heroes.

[ slide 71 ]

Page 72: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

1. What the variables are.

2. What constitutes a step.

Filling a jug is a single step.

No intermediate states.[small : 0big : 3

]→ → →

[small : 1big : 3

] [small : 2big : 3

] [small : 3big : 3

]

Filling a jug is a single step.

There’s no intermediate partially-filled state or states.

This is the simplest abstraction of the behavior of real jugs and water forthe particular problem faced by our heroes.

[ slide 72 ]

Page 73: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

1. What the variables are.

2. What constitutes a step.

Filling a jug is a single step.

No intermediate states.[small : 0big : 3

]→ → →

[small : 1big : 3

] [small : 2big : 3

] [small : 3big : 3

]��

����

���PPPPPPPPP

Filling a jug is a single step.

There’s no intermediate partially-filled state or states.

This is the simplest abstraction of the behavior of real jugs and water forthe particular problem faced by our heroes.

[ slide 73 ]

Page 74: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

What did we learn from this behavior?

1. What the variables are.

2. What constitutes a step.

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

Filling a jug is a single step.

There’s no intermediate partially-filled state or states.

This is the simplest abstraction of the behavior of real jugs and water forthe particular problem faced by our heroes.

[ slide 74 ]

Page 75: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]Simplest abstraction of real jugs and water

for this problem.

Filling a jug is a single step.

There’s no intermediate partially-filled state or states.

This is the simplest abstraction of the behavior of real jugs and water forthe particular problem faced by our heroes.

[ slide 75 ]

Page 76: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]Simplest abstraction of real jugs and water

for this problem.

Filling a jug is a single step.

There’s no intermediate partially-filled state or states.

This is the simplest abstraction of the behavior of real jugs and water forthe particular problem faced by our heroes.

[ slide 76 ]

Page 77: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

Real specifications are written toeliminate some kinds of errors.

Like getting blown up.

Real specifications are written for a purpose.Usually to eliminate some particular kinds of errors.

For example, to avoid getting blown up.

[ slide 77 ]

Page 78: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 0

] [small : 3big : 0

] [small : 1big : 5

] [small : 1big : 0

]→ → → → → · · ·

[small : 3big : 3

]→

[small : 0big : 3

]

Real specifications are written toeliminate some kinds of errors.

Like getting blown up.

Real specifications are written for a purpose.Usually to eliminate some particular kinds of errors.

For example, to avoid getting blown up.

[ slide 78 ]

Page 79: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

THE SPECIFICATION

We can now start writing the actual TLA+ specification.

[ slide 79 ]

Page 80: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Beginning of module.

The spec is in a module called DieHard .

As in our Simple Program example, the EXTENDS statement importsoperators of arithmeticand the VARIABLES statement declares our two variables.

In TLA+ we don’t write type declarations.

[ slide 80 ]

Page 81: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Imports operators of arithmetic.

The spec is in a module called DieHard .

As in our Simple Program example, the EXTENDS statement importsoperators of arithmeticand the VARIABLES statement declares our two variables.

In TLA+ we don’t write type declarations.

[ slide 81 ]

Page 82: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Declares the variables.

The spec is in a module called DieHard .

As in our Simple Program example, the EXTENDS statement importsoperators of arithmeticand the VARIABLES statement declares our two variables.

In TLA+ we don’t write type declarations.

[ slide 82 ]

Page 83: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLA+ has no type declarations.

Type correctness means variables havesensible values.

The spec is in a module called DieHard .

As in our Simple Program example, the EXTENDS statement importsoperators of arithmeticand the VARIABLES statement declares our two variables.

In TLA+ we don’t write type declarations.

[ slide 83 ]

Page 84: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLA+ has no type declarations.

Type correctness means variables havesensible values.

Type correctness means that all the variables have sensible values.

It’s a good idea to define a formula that asserts type correctness.

It helps a reader to understand the spec.

And TLC can type-check the spec by checking that this formula is alwaystrue.

[ slide 84 ]

Page 85: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

We define a formula that asserts typecorrectness.

Helps to understand spec.

TLC can check that it’s always true.

Type correctness means that all the variables have sensible values.

It’s a good idea to define a formula that asserts type correctness.

It helps a reader to understand the spec.

And TLC can type-check the spec by checking that this formula is alwaystrue.

[ slide 85 ]

Page 86: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

We define a formula that asserts typecorrectness.

Helps to understand spec.

TLC can check that it’s always true.

Type correctness means that all the variables have sensible values.

It’s a good idea to define a formula that asserts type correctness.

It helps a reader to understand the spec.

And TLC can type-check the spec by checking that this formula is alwaystrue.

[ slide 86 ]

Page 87: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

We define a formula that asserts typecorrectness.

Helps to understand spec.

TLC can check that it’s always true.

Type correctness means that all the variables have sensible values.

It’s a good idea to define a formula that asserts type correctness.

It helps a reader to understand the spec.

And TLC can type-check the spec by checking that this formula is alwaystrue.

[ slide 87 ]

Page 88: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

We define a formula that asserts typecorrectness.

Helps to understand spec.

TLC can check that it’s always true.

I like to call this formula TypeOK .

It asserts that the value of small is an integer from 0 through 3.and the value of big is an integer from 0 through 5.

This definition is not part of the spec.

Removing it doesn’t change anything.

[ slide 88 ]

Page 89: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

I like to call this formula TypeOK .

It asserts that the value of small is an integer from 0 through 3.and the value of big is an integer from 0 through 5.

This definition is not part of the spec.

Removing it doesn’t change anything.

[ slide 89 ]

Page 90: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

I like to call this formula TypeOK .

It asserts that the value of small is an integer from 0 through 3.and the value of big is an integer from 0 through 5.

This definition is not part of the spec.

Removing it doesn’t change anything.

[ slide 90 ]

Page 91: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This definition is not part of the spec.

Removing it doesn’t change anything.

I like to call this formula TypeOK .

It asserts that the value of small is an integer from 0 through 3.and the value of big is an integer from 0 through 5.

This definition is not part of the spec.

Removing it doesn’t change anything.

[ slide 91 ]

Page 92: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This definition is not part of the spec.

Removing it doesn’t change anything.

I like to call this formula TypeOK .

It asserts that the value of small is an integer from 0 through 3.and the value of big is an integer from 0 through 5.

This definition is not part of the spec.

Removing it doesn’t change anything.

[ slide 92 ]

Page 93: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Initial-State Formula

The initial-state formula.

As usual, let’s name it Init .

It asserts that both jugs are empty.

[ slide 93 ]

Page 94: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Initial-State Formula

The initial-state formula.

As usual, let’s name it Init .

It asserts that both jugs are empty.

[ slide 94 ]

Page 95: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Initial-State Formula

The initial-state formula.

As usual, let’s name it Init .

It asserts that both jugs are empty.

[ slide 95 ]

Page 96: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

THE NEXT - STATE FORMULA

The next-state formula.

[ slide 96 ]

Page 97: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The next-state formula describes all permitted steps.

It’s usually written as F1 or F2 or (and so on) ,

where each formula F allows a different kind of step.

[ slide 97 ]

Page 98: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The next-state formula describes all permitted steps.

It’s usually written as F1 or F2 or (and so on) ,

where each formula F allows a different kind of step.

[ slide 98 ]

Page 99: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The next-state formula describes all permitted steps.

It’s usually written as F1 or F2 or (and so on) ,

where each formula F allows a different kind of step.

[ slide 99 ]

Page 100: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The behavior we just wrote has 3 different kinds of steps:

Steps that fill a jug.

Steps that empty a jug.

And steps that pour from one jug into the other.

[ slide 100 ]

Page 101: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The behavior we just wrote has 3 different kinds of steps:

Steps that fill a jug.

Steps that empty a jug.

And steps that pour from one jug into the other.

[ slide 101 ]

Page 102: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The behavior we just wrote has 3 different kinds of steps:

Steps that fill a jug.

Steps that empty a jug.

And steps that pour from one jug into the other.

[ slide 102 ]

Page 103: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Next-State Formula

The next-state formula describes all permitted steps.

It’s usually written as F1 ∨ F2 ∨ . . . ∨ Fn ,where each Fi allows a different kind of step.

The behavior we wrote has 3 kinds of steps:

– Fill a jug.

– Empty a jug.

– Pour from one jug into the other.

The behavior we just wrote has 3 different kinds of steps:

Steps that fill a jug.

Steps that empty a jug.

And steps that pour from one jug into the other.

[ slide 103 ]

Page 104: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

As usual, we call the next-state formula Next .

First we allow steps that fill a jug.There are two jugs, so we have two possible kinds of steps.

Steps that fill the small jug. And steps that fill the big jug.

[ slide 104 ]

Page 105: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

– Fill a jug.

As usual, we call the next-state formula Next .

First we allow steps that fill a jug.There are two jugs, so we have two possible kinds of steps.

Steps that fill the small jug. And steps that fill the big jug.

[ slide 105 ]

Page 106: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill small jug.

As usual, we call the next-state formula Next .

First we allow steps that fill a jug.There are two jugs, so we have two possible kinds of steps.

Steps that fill the small jug. And steps that fill the big jug.

[ slide 106 ]

Page 107: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Fill big jug.

As usual, we call the next-state formula Next .

First we allow steps that fill a jug.There are two jugs, so we have two possible kinds of steps.

Steps that fill the small jug. And steps that fill the big jug.

[ slide 107 ]

Page 108: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

– Empty a jug.

Similarly for steps that empty a jug.

And there are two kinds of steps that pour from one jug to the other.

Steps that pour from the small jug to the big jug.

And steps that pour from the big jug to the small jug.

[ slide 108 ]

Page 109: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

– Empty a jug.

Similarly for steps that empty a jug.

And there are two kinds of steps that pour from one jug to the other.

Steps that pour from the small jug to the big jug.

And steps that pour from the big jug to the small jug.

[ slide 109 ]

Page 110: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

– Pour from one juginto the other.

Similarly for steps that empty a jug.

And there are two kinds of steps that pour from one jug to the other.

Steps that pour from the small jug to the big jug.

And steps that pour from the big jug to the small jug.

[ slide 110 ]

Page 111: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

From small jug to big jug.

Similarly for steps that empty a jug.

And there are two kinds of steps that pour from one jug to the other.

Steps that pour from the small jug to the big jug.

And steps that pour from the big jug to the small jug.

[ slide 111 ]

Page 112: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

From big jug to small jug.

Similarly for steps that empty a jug.

And there are two kinds of steps that pour from one jug to the other.

Steps that pour from the small jug to the big jug.

And steps that pour from the big jug to the small jug.

[ slide 112 ]

Page 113: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Names must be defined before they are used.

The definitions of these names must precedethis definition of Next .

In TLA+, names must be defined before they’re used.

The definitions of FillSmall , FillBig , etc. must precedethis definition of Next .

[ slide 113 ]

Page 114: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Names must be defined before they are used.

The definitions of these names must precedethis definition of Next .

In TLA+, names must be defined before they’re used.

The definitions of FillSmall , FillBig , etc. must precedethis definition of Next .

[ slide 114 ]

Page 115: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Names must be defined before they are used.

The definitions of these names must precedethis definition of Next .

In TLA+, names must be defined before they’re used.

The definitions of FillSmall , FillBig , etc. must precedethis definition of Next .

[ slide 115 ]

Page 116: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Most people would write this definition.

Stop the video now and figure outwhy it’s wrong.

We now define FillSmall .

Most people first learning TLA+ would write this definition.

Stop the video now and figure out why it’s wrong.

If you didn’t figure it out, it means that you’re thinking of this as anassignment statement that sets small to 3. It’s not.

[ slide 116 ]

Page 117: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Most people would write this definition.

Stop the video now and figure outwhy it’s wrong.

We now define FillSmall .

Most people first learning TLA+ would write this definition.

Stop the video now and figure out why it’s wrong.

If you didn’t figure it out, it means that you’re thinking of this as anassignment statement that sets small to 3. It’s not.

[ slide 117 ]

Page 118: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Most people would write this definition.

Stop the video now and figure outwhy it’s wrong.

We now define FillSmall .

Most people first learning TLA+ would write this definition.

Stop the video now and figure out why it’s wrong.

If you didn’t figure it out, it means that you’re thinking of this as anassignment statement that sets small to 3. It’s not.

[ slide 118 ]

Page 119: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

If you didn’t figure it out, you’re thinking of this assetting small to 3.

It’s a formula that’s true for some stepsand false for others.

It’s true for any step in whichsmall = 3 in the second state.

We now define FillSmall .

Most people first learning TLA+ would write this definition.

Stop the video now and figure out why it’s wrong.

If you didn’t figure it out, it means that you’re thinking of this as anassignment statement that sets small to 3. It’s not.

[ slide 119 ]

Page 120: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

If you didn’t figure it out, you’re thinking of this assetting small to 3.

It’s a formula that’s true for some stepsand false for others.

It’s true for any step in whichsmall = 3 in the second state.

It’s a formula that’s true for some steps and false for others.

It’s true for any step in which the value of small in the second state is 3.

It’s true for this step that appeared in the behavior we constructed.

[ slide 120 ]

Page 121: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

If you didn’t figure it out, you’re thinking of this assetting small to 3.

It’s a formula that’s true for some stepsand false for others.

It’s true for any step in whichsmall = 3 in the second state.

It’s a formula that’s true for some steps and false for others.

It’s true for any step in which the value of small in the second state is 3.

It’s true for this step that appeared in the behavior we constructed.

[ slide 121 ]

Page 122: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 3

]→

[small : 3big : 3

][small : 0big : 3

]→

[small : 3big :

√7

][small : 0big : 3

]→

[small : 3big : “abc”

]

It’s a formula that’s true for some steps and false for others.

It’s true for any step in which the value of small in the second state is 3.

It’s true for this step that appeared in the behavior we constructed.

[ slide 122 ]

Page 123: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 3

]→

[small : 3big : 3

][small : 0big : 3

]→

[small : 3big :

√7

][small : 0big : 3

]→

[small : 3big : “abc”

]

It’s a formula that’s true for some steps and false for others.

It’s true for any step in which the value of small in the second state is 3.

It’s true for this step that appeared in the behavior we constructed.

[ slide 123 ]

Page 124: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 3

]→

[small : 3big : 3

][small : 0big : 3

]→

[small : 3big :

√7

][small : 0big : 3

]→

[small : 3big : “abc”

]

It’s also true for this step in which big equals the square root of 7 in thesecond state.

And it’s also true for this step in which big equals the string abc in the secondstate.

[ slide 124 ]

Page 125: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 3

]→

[small : 3big : 3

][small : 0big : 3

]→

[small : 3big :

√7

][small : 0big : 3

]→

[small : 3big : “abc”

]

It’s also true for this step in which big equals the square root of 7 in thesecond state.

And it’s also true for this step in which big equals the string abc in the secondstate.

[ slide 125 ]

Page 126: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[small : 0big : 3

]→

[small : 3big : 3

][small : 0big : 3

]→

[small : 3big :

√7

][small : 0big : 3

]→

[small : 3big : “abc”

] Should be falsefor these.

Of course, these two steps shouldn’t be allowed, so FillSmall should equalfalse for them.

And the correct definition should require the value of big to be unchanged.

[ slide 126 ]

Page 127: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This is the correct definition.

Of course, these two steps shouldn’t be allowed, so FillSmall should equalfalse for them.

And the correct definition should require the value of big to be unchanged.

[ slide 127 ]

Page 128: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Most people think this shouldn’t be needed.

That’s a bad idea! It’s not math.

When they first see TLA+, most computer engineers and computer scientiststhink that this part of the formula shouldn’t be needed.

And that you shouldn’t have to say what’s left unchanged.

My years of experience writing specifications and a couple of thousand yearsof mathematics say that’s a bad idea.

[ slide 128 ]

Page 129: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Most people think this shouldn’t be needed.

That’s a bad idea! It’s not math.

When they first see TLA+, most computer engineers and computer scientiststhink that this part of the formula shouldn’t be needed.

And that you shouldn’t have to say what’s left unchanged.

My years of experience writing specifications and a couple of thousand yearsof mathematics say that’s a bad idea.

[ slide 129 ]

Page 130: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Most people think this shouldn’t be needed.

That’s a bad idea! It’s not math.

It would leave the simple, elegant realm of mathematics — and enter themore complicated world of programming languages.

[ slide 130 ]

Page 131: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The definition of FillBig is similar.

The definition of FillBig is similar.

[ slide 131 ]

Page 132: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

POURING BETWEEN JUGS

Pouring from one jug into another.

[ slide 132 ]

Page 133: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 133 ]

Page 134: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 134 ]

Page 135: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 135 ]

Page 136: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 136 ]

Page 137: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 137 ]

Page 138: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 138 ]

Page 139: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 139 ]

Page 140: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 140 ]

Page 141: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 141 ]

Page 142: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 142 ]

Page 143: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 143 ]

Page 144: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 144 ]

Page 145: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 145 ]

Page 146: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 146 ]

Page 147: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 147 ]

Page 148: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 148 ]

Page 149: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

We now define SmallToBig .

In the behavior we constructed, we saw that there are two cases:

In case 1, there is room in the big jug for all the water in the small jug.Here was that case.

In case 2, there isn’t room in the big jug for all the water in the small jug.Here was that case.

[ slide 149 ]

Page 150: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 150 ]

Page 151: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

1. There is room: empty small .

2. There isn’t room: fill big .

There are two cases:

1. There is room in big

for the water in small .

2. There isn’t room in big

for the water in small .

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 151 ]

Page 152: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

2. There isn’t room: fill big .

Put water from small into big , emptying small .

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 152 ]

Page 153: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

2. There isn’t room: fill big .

Put water from small into big , emptying small .

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 153 ]

Page 154: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 154 ]

Page 155: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

??

Problem: Complete the definition of SmallToBig

and write the definition of BigToSmall .

Stop the video and solve it now.

You’ll check your solution later.

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 155 ]

Page 156: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

??

Problem: Complete the definition of SmallToBig

and write the definition of BigToSmall .

Stop the video and solve it now.

You’ll check your solution later.

Which case it is depends on the total amount of water in the two jugs.

In case 1, we put all the water from the small jug into the big jug, whichempties the small jug.

Case 2 is left as a problem. As is writing the definition of BigToSmall .

[ slide 156 ]

Page 157: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

??

Problem: Complete the definition of SmallToBig

and write the definition of BigToSmall .

Stop the video and solve it now.

You’ll check your solution later.

Stop the video and solve it now, writing down your solution.

You’ll check your solution later.

[ slide 157 ]

Page 158: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

??

Problem: Complete the definition of SmallToBig

and write the definition of BigToSmall .

Stop the video and solve it now.

You’ll check your solution later.

Stop the video and solve it now, writing down your solution.

You’ll check your solution later.

[ slide 158 ]

Page 159: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

SAVING OUR HEROES

We’ll now use TLC to save our heroes.

[ slide 159 ]

Page 160: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Open the Toolbox.

Open a new spec named DieHard .

Open the Toolbox.

And then open a new spec named DieHard .

[ slide 160 ]

Page 161: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Open the Toolbox.

Open a new spec named DieHard .

Open the Toolbox.

And then open a new spec named DieHard .

[ slide 161 ]

Page 162: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 162 ]

Page 163: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 163 ]

Page 164: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 164 ]

Page 165: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 165 ]

Page 166: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 166 ]

Page 167: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 167 ]

Page 168: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 168 ]

Page 169: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 169 ]

Page 170: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 170 ]

Page 171: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 171 ]

Page 172: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Remember you click on File. Then on Open Spec. Then onAdd New Spec, which opens This window. Then click on Browse whichraisesa file browser window—probably on the folder in which you put theSimpleProgram spec. Select any folder and enter the file name DieHard .Then click on Open and then on Finish which opens

[ slide 172 ]

Page 173: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Stop the video and copy the body of the spec.

Paste it here.

An empty spec named diehard.

Stop the video now and copy the body of the specification that we just wrote.

and then paste the text in the module here.

[ slide 173 ]

Page 174: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Stop the video and copy the body of the spec.

Paste it here.

An empty spec named diehard.

Stop the video now and copy the body of the specification that we just wrote.

and then paste the text in the module here.

[ slide 174 ]

Page 175: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Stop the video and copy the body of the spec.

Paste it here.

An empty spec named diehard.

Stop the video now and copy the body of the specification that we just wrote.

and then paste the text in the module here.

[ slide 175 ]

Page 176: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The module contains thecomplete definitions ofSmallToBig and BigToSmall .

But don’t lookat them yet.

And here’s what you should see.

The module contains the complete definitions of SmallToBig andBigToSmall But don’t look at them until after we’ve saved our heroes.

And first, you have to save the module – which you can do by typing ControlS.

[ slide 176 ]

Page 177: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The module contains thecomplete definitions ofSmallToBig and BigToSmall .

But don’t lookat them yet.

And here’s what you should see.

The module contains the complete definitions of SmallToBig andBigToSmall But don’t look at them until after we’ve saved our heroes.

And first, you have to save the module – which you can do by typing ControlS.

[ slide 177 ]

Page 178: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The module contains thecomplete definitions ofSmallToBig and BigToSmall .

But don’t lookat them yet.

And here’s what you should see.

The module contains the complete definitions of SmallToBig andBigToSmall But don’t look at them until after we’ve saved our heroes.

And first, you have to save the module – which you can do by typing ControlS.

[ slide 178 ]

Page 179: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save the module.(Type Ctl+S .)

And here’s what you should see.

The module contains the complete definitions of SmallToBig andBigToSmall But don’t look at them until after we’ve saved our heroes.

And first, you have to save the module – which you can do by typing ControlS.

[ slide 179 ]

Page 180: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save the module.(Type Ctl+S .)

And here’s what you should see.

The module contains the complete definitions of SmallToBig andBigToSmall But don’t look at them until after we’ve saved our heroes.

And first, you have to save the module – which you can do by typing ControlS.

[ slide 180 ]

Page 181: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To run TLC, we create a model.

To run TLC, we create a model by

Clicking on the TLC Model Checker menu

Selecting NewModel

Entering a model name and

Clicking OK.

[ slide 181 ]

Page 182: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To run TLC, we create a model.

To run TLC, we create a model by

Clicking on the TLC Model Checker menu

Selecting NewModel

Entering a model name and

Clicking OK.

[ slide 182 ]

Page 183: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To run TLC, we create a model.

To run TLC, we create a model by

Clicking on the TLC Model Checker menu

Selecting NewModel

Entering a model name and

Clicking OK.

[ slide 183 ]

Page 184: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To run TLC, we create a model.

To run TLC, we create a model by

Clicking on the TLC Model Checker menu

Selecting NewModel

Entering a model name and

Clicking OK.

[ slide 184 ]

Page 185: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To run TLC, we create a model.

To run TLC, we create a model by

Clicking on the TLC Model Checker menu

Selecting NewModel

Entering a model name and

Clicking OK.

[ slide 185 ]

Page 186: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This raises the Model Overview page

Where the Toolbox has filled in the initial formula and thenext-state formula.

Let’s now run TLC by clicking on this button.

[ slide 186 ]

Page 187: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Initial and next-state formulas

This raises the Model Overview page

Where the Toolbox has filled in the initial formula and thenext-state formula.

Let’s now run TLC by clicking on this button.

[ slide 187 ]

Page 188: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Run TLC.

This raises the Model Overview page

Where the Toolbox has filled in the initial formula and thenext-state formula.

Let’s now run TLC by clicking on this button.

[ slide 188 ]

Page 189: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC quickly finishes, displaying the Model Checking Results page whichreports that it found no errors. We didn’t ask TLC to check anything, so thisjust means that the spec is one that it could execute.

TLC also reports that it found 16 reachable states which are states thatoccur in some behavior allowed by the spec.

[ slide 189 ]

Page 190: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC quickly finishes, displaying the Model Checking Results page whichreports that it found no errors. We didn’t ask TLC to check anything, so thisjust means that the spec is one that it could execute.

TLC also reports that it found 16 reachable states which are states thatoccur in some behavior allowed by the spec.

[ slide 190 ]

Page 191: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC reports no errors.

TLC quickly finishes, displaying the Model Checking Results page whichreports that it found no errors. We didn’t ask TLC to check anything, so thisjust means that the spec is one that it could execute.

TLC also reports that it found 16 reachable states which are states thatoccur in some behavior allowed by the spec.

[ slide 191 ]

Page 192: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC reports no errors.

This means it couldrun the spec.

TLC quickly finishes, displaying the Model Checking Results page whichreports that it found no errors. We didn’t ask TLC to check anything, so thisjust means that the spec is one that it could execute.

TLC also reports that it found 16 reachable states which are states thatoccur in some behavior allowed by the spec.

[ slide 192 ]

Page 193: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC found 16reachable states.

TLC quickly finishes, displaying the Model Checking Results page whichreports that it found no errors. We didn’t ask TLC to check anything, so thisjust means that the spec is one that it could execute.

TLC also reports that it found 16 reachable states which are states thatoccur in some behavior allowed by the spec.

[ slide 193 ]

Page 194: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC found 16reachable states.

(States occurring in somebehavior allowed by spec.)

TLC quickly finishes, displaying the Model Checking Results page whichreports that it found no errors. We didn’t ask TLC to check anything, so thisjust means that the spec is one that it could execute.

TLC also reports that it found 16 reachable states which are states thatoccur in some behavior allowed by the spec.

[ slide 194 ]

Page 195: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Let’s check type correctness(every reachable statesatisfies TypeOK ).

Let’s now check type correctness – which means that every reachable statesatisfies formula TypeOK .

Remember that this formula asserts that each variable has a reasonablevalue.

To do this, we must go back to the Model Overview page.

[ slide 195 ]

Page 196: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Let’s check type correctness(every reachable statesatisfies TypeOK ).

Let’s now check type correctness – which means that every reachable statesatisfies formula TypeOK .

Remember that this formula asserts that each variable has a reasonablevalue.

To do this, we must go back to the Model Overview page.

[ slide 196 ]

Page 197: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Let’s check type correctness(every reachable statesatisfies TypeOK ).

Let’s now check type correctness – which means that every reachable statesatisfies formula TypeOK .

Remember that this formula asserts that each variable has a reasonablevalue.

To do this, we must go back to the Model Overview page.

[ slide 197 ]

Page 198: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Let’s now check type correctness – which means that every reachable statesatisfies formula TypeOK .

Remember that this formula asserts that each variable has a reasonablevalue.

To do this, we must go back to the Model Overview page.

[ slide 198 ]

Page 199: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A formula that is true in every reachable state is called an invariant. To haveTLC check an invariant Open the Invariants section of the model overviewpage.

[ slide 199 ]

Page 200: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A formula true in everyreachable state is calledan invariant.

A formula that is true in every reachable state is called an invariant. To haveTLC check an invariant Open the Invariants section of the model overviewpage.

[ slide 200 ]

Page 201: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A formula that is true in every reachable state is called an invariant. To haveTLC check an invariant Open the Invariants section of the model overviewpage.

[ slide 201 ]

Page 202: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 202 ]

Page 203: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 203 ]

Page 204: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 204 ]

Page 205: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 205 ]

Page 206: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 206 ]

Page 207: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 207 ]

Page 208: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 208 ]

Page 209: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Run TLC.

Click on Add.

Enter TypeOK. And click on Finish.

And run TLC on the model again.

[ slide 209 ]

Page 210: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The Model Checking Results page

again shows that TLC found no errors.

[ slide 210 ]

Page 211: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC reports no errors.

The Model Checking Results page

again shows that TLC found no errors.

[ slide 211 ]

Page 212: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Saving Our Heroes

The four gallons must be in the big jug.

We let TLC check if big 6= 4 is an invariant.

We add this invariant to the model.

Now we’re ready to save our heroes.

The four gallons of water our heroes need must be in the big jug.

We let TLC check if big not equal to 4 is an invariant.

[ slide 212 ]

Page 213: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Saving Our Heroes

The four gallons must be in the big jug.

We let TLC check if big 6= 4 is an invariant.

We add this invariant to the model.

Now we’re ready to save our heroes.

The four gallons of water our heroes need must be in the big jug.

We let TLC check if big not equal to 4 is an invariant.

[ slide 213 ]

Page 214: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Saving Our Heroes

The four gallons must be in the big jug.

We let TLC check if big 6= 4 is an invariant.

We add this invariant to the model.

Now we’re ready to save our heroes.

The four gallons of water our heroes need must be in the big jug.

We let TLC check if big not equal to 4 is an invariant.

[ slide 214 ]

Page 215: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Saving Our Heroes

The four gallons must be in the big jug.

We let TLC check if big 6= 4 is an invariant.

If it isn’t, TLC will show us a behaviorending in a state with big 6= 4 false.

We add this invariant to the model.

If it isn’t, TLC will show us a behavior ending in a state with big 6= 4 false – abehavior that tells our heroes what they have to do to put 4 gallons in the bigjug.

In TLA+, not equal is written in ASCII as either forward slash equal-sign orsharp (also called pound sign).

We now add this invariant to the model.

[ slide 215 ]

Page 216: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Saving Our Heroes

The four gallons must be in the big jug.

We let TLC check if big 6= 4 is an invariant.6= is written in ASCII as /= or #

We add this invariant to the model.

If it isn’t, TLC will show us a behavior ending in a state with big 6= 4 false – abehavior that tells our heroes what they have to do to put 4 gallons in the bigjug.

In TLA+, not equal is written in ASCII as either forward slash equal-sign orsharp (also called pound sign).

We now add this invariant to the model.

[ slide 216 ]

Page 217: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Saving Our Heroes

The four gallons must be in the big jug.

We let TLC check if big 6= 4 is an invariant.

We add this invariant to the model.

If it isn’t, TLC will show us a behavior ending in a state with big 6= 4 false – abehavior that tells our heroes what they have to do to put 4 gallons in the bigjug.

In TLA+, not equal is written in ASCII as either forward slash equal-sign orsharp (also called pound sign).

We now add this invariant to the model.

[ slide 217 ]

Page 218: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 218 ]

Page 219: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 219 ]

Page 220: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 220 ]

Page 221: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 221 ]

Page 222: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 222 ]

Page 223: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 223 ]

Page 224: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Run TLC.

In the Invariants section of the model overview page

We add another invariant big not equal to 4

And we run TLC.

[ slide 224 ]

Page 225: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This time TLC reports an error.

And the Toolbox opens this error window.

Which tells us that the invariant was violated And displays this error trace.

The error trace is a behavior satisfying the spec ending in this state

[ slide 225 ]

Page 226: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This time TLC reports an error.

And the Toolbox opens this error window.

Which tells us that the invariant was violated And displays this error trace.

The error trace is a behavior satisfying the spec ending in this state

[ slide 226 ]

Page 227: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This time TLC reports an error.

And the Toolbox opens this error window.

Which tells us that the invariant was violated And displays this error trace.

The error trace is a behavior satisfying the spec ending in this state

[ slide 227 ]

Page 228: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

This time TLC reports an error.

And the Toolbox opens this error window.

Which tells us that the invariant was violated And displays this error trace.

The error trace is a behavior satisfying the spec ending in this state

[ slide 228 ]

Page 229: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A behavior ending in state[big : 4small : 3

]

This time TLC reports an error.

And the Toolbox opens this error window.

Which tells us that the invariant was violated And displays this error trace.

The error trace is a behavior satisfying the spec ending in this state

[ slide 229 ]

Page 230: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A behavior ending in state

with the invariant false.

[big : 4small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 230 ]

Page 231: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 231 ]

Page 232: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 232 ]

Page 233: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]→

[big : 5small : 0

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 233 ]

Page 234: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 234 ]

Page 235: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]→

[big : 2small : 0

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 235 ]

Page 236: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]→

[big : 2small : 0

]→

[big : 0small : 2

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 236 ]

Page 237: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]→

[big : 2small : 0

]→

[big : 0small : 2

]→

[big : 5small : 2

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 237 ]

Page 238: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

The complete behavior:[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]→

[big : 2small : 0

]→

[big : 0small : 2

]→

[big : 5small : 2

]→

[big : 4small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 238 ]

Page 239: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]→

[big : 2small : 0

]→

[big : 0small : 2

]→

[big : 5small : 2

]→

[big : 4small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 239 ]

Page 240: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[big : 0small : 0

]→

[big : 5small : 0

]→

[big : 2small : 3

]→

[big : 2small : 0

]→

[big : 0small : 2

]→

[big : 5small : 2

]→

[big : 4small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 240 ]

Page 241: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

[big : 5small : 0

]→

[big : 2small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 241 ]

Page 242: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Double-click here.

[big : 5small : 0

]→

[big : 2small : 3

]

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 242 ]

Page 243: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 243 ]

Page 244: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

a state in which the invariant equals false.

It shows this complete behavior From this behavior, our heroes should be able to see how to get 4gallons of water in the big jug. But they might not be the brightest bulbs on the block, and they may need helpfiguring out how to get from one state to the next. The Toolbox provides that help.

To see why this step is allowed by the spec Double-click here to find the part of the next-state formula that allowsthis step And even Hollywood actors should be able to figure out that they have to pour the big jug into the smalljug.

[ slide 244 ]

Page 245: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

SmallToBig AND BigToSmall

Formulas SmallToBig and BigToSmall .

[ slide 245 ]

Page 246: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Now that we’ve saved our heroes, let’s take a look at the definitions ofSmallToBig and BigToSmall .

Let’s start with SmallToBig .

[ slide 246 ]

Page 247: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Now that we’ve saved our heroes, let’s take a look at the definitions ofSmallToBig and BigToSmall .

Let’s start with SmallToBig .

[ slide 247 ]

Page 248: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

≤ is typed as =<

Notice that less than or equal is represented in ASCII as equal-signless-than.

Remember that this is the case in which the big jug is filled fromthe small one.

The amount poured into the big jug is removed from the small jug.

[ slide 248 ]

Page 249: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Notice that less than or equal is represented in ASCII as equal-signless-than.

Remember that this is the case in which the big jug is filled fromthe small one.

The amount poured into the big jug is removed from the small jug.

[ slide 249 ]

Page 250: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

big is filled.

Notice that less than or equal is represented in ASCII as equal-signless-than.

Remember that this is the case in which the big jug is filled fromthe small one.

The amount poured into the big jug is removed from the small jug.

[ slide 250 ]

Page 251: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

amount poured

Notice that less than or equal is represented in ASCII as equal-signless-than.

Remember that this is the case in which the big jug is filled fromthe small one.

The amount poured into the big jug is removed from the small jug.

[ slide 251 ]

Page 252: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Someone who hasn’t seen TLA+ before would think this is wrong becausethis value of big Is set to 5 here.

That’s because she thinks of this as two assignment statements.But you know that it’s actually a formula that specifies allowed steps.And that and is commutative, soChanging the order of the two sub-formulas makes no difference.

[ slide 252 ]

Page 253: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Someone who hasn’t seen TLA+ before would think this is wrong becausethis value of big Is set to 5 here.

That’s because she thinks of this as two assignment statements.But you know that it’s actually a formula that specifies allowed steps.And that and is commutative, soChanging the order of the two sub-formulas makes no difference.

[ slide 253 ]

Page 254: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Someone who hasn’t seen TLA+ before would think this is wrong becausethis value of big Is set to 5 here.

That’s because she thinks of this as two assignment statements.But you know that it’s actually a formula that specifies allowed steps.And that and is commutative, soChanging the order of the two sub-formulas makes no difference.

[ slide 254 ]

Page 255: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A ∧ B = B ∧ A

Someone who hasn’t seen TLA+ before would think this is wrong becausethis value of big Is set to 5 here.

That’s because she thinks of this as two assignment statements.But you know that it’s actually a formula that specifies allowed steps.And that and is commutative, soChanging the order of the two sub-formulas makes no difference.

[ slide 255 ]

Page 256: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

A ∧ B = B ∧ A

Someone who hasn’t seen TLA+ before would think this is wrong becausethis value of big Is set to 5 here.

That’s because she thinks of this as two assignment statements.But you know that it’s actually a formula that specifies allowed steps.And that and is commutative, soChanging the order of the two sub-formulas makes no difference.

[ slide 256 ]

Page 257: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Someone who hasn’t seen TLA+ before would think this is wrong becausethis value of big Is set to 5 here.

That’s because she thinks of this as two assignment statements.But you know that it’s actually a formula that specifies allowed steps.And that and is commutative, soChanging the order of the two sub-formulas makes no difference.

[ slide 257 ]

Page 258: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

You can look at the definition of BigToSmall in the module by yourself later.

[ slide 258 ]

Page 259: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 259 ]

Page 260: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

WARNING !

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 260 ]

Page 261: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

= is also commutative

so

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 261 ]

Page 262: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

= is also commutative

so

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 262 ]

Page 263: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

= is also commutative

so is equivalent to .

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 263 ]

Page 264: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

These two specs are equivalent.

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 264 ]

Page 265: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

These two specs are equivalent.

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 265 ]

Page 266: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

These two specs are equivalent.

Here’s a warning about writing specs.

The equality operator is also commutative. so small prime equals 0 iscompletely equivalent to 0 equals small prime.

These two specs are equivalent. .

[ slide 266 ]

Page 267: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

These two specs are equivalent.

The TLAPS proof system treats them the same.

And the TLAPS proof system treats them exactly the same.

But TLC handles only this one.

It reports an error if you run it on this one.

[ slide 267 ]

Page 268: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

These two specs are equivalent.

But TLC handles only this one.

And the TLAPS proof system treats them exactly the same.

But TLC handles only this one.

It reports an error if you run it on this one.

[ slide 268 ]

Page 269: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

```̀

These two specs are equivalent.

It reports an error on this one.

And the TLAPS proof system treats them exactly the same.

But TLC handles only this one.

It reports an error if you run it on this one.

[ slide 269 ]

Page 270: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are many ways to write a correctspecification.

TLC can almost always handle the onesmost engineers naturally write.

Later, you’ll learn what specs TLC can handle.

There are many ways to write a correct specification.

TLC can almost always handle the ones most engineers naturally write.

Later, you’ll learn what specs TLC can handle.

[ slide 270 ]

Page 271: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are many ways to write a correctspecification.

TLC can almost always handle the onesmost engineers naturally write.

Later, you’ll learn what specs TLC can handle.

There are many ways to write a correct specification.

TLC can almost always handle the ones most engineers naturally write.

Later, you’ll learn what specs TLC can handle.

[ slide 271 ]

Page 272: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

There are many ways to write a correctspecification.

TLC can almost always handle the onesmost engineers naturally write.

Later, you’ll learn what specs TLC can handle.

There are many ways to write a correct specification.

TLC can almost always handle the ones most engineers naturally write.

Later, you’ll learn what specs TLC can handle.

[ slide 272 ]

Page 273: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

For now, follow this simple rule:

Use a primed variable v ′ onlyin one of these two kinds offormulas:

v ′ = . . . and v ′ ∈ . . .bb ""no primed variables

We’ll relax this rule later.

For now, just follow this simple rule:

Use a primed variable v -prime only in one of these two kinds of formulaswhere dot-dot-dot is an expression not containing primes.

We’ll relax this rule later.

[ slide 273 ]

Page 274: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

For now, follow this simple rule:

Use a primed variable v ′ onlyin one of these two kinds offormulas:

v ′ = . . . and v ′ ∈ . . .bb ""no primed variables

We’ll relax this rule later.

For now, just follow this simple rule:

Use a primed variable v -prime only in one of these two kinds of formulaswhere dot-dot-dot is an expression not containing primes.

We’ll relax this rule later.

[ slide 274 ]

Page 275: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

For now, follow this simple rule:

Use a primed variable v ′ onlyin one of these two kinds offormulas:

v ′ = . . . and v ′ ∈ . . .bb ""no primed variables

We’ll relax this rule later.

For now, just follow this simple rule:

Use a primed variable v -prime only in one of these two kinds of formulaswhere dot-dot-dot is an expression not containing primes.

We’ll relax this rule later.

[ slide 275 ]

Page 276: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

For now, follow this simple rule:

Use a primed variable v ′ onlyin one of these two kinds offormulas:

v ′ = . . . and v ′ ∈ . . .bb ""no primed variables

We’ll relax this rule later.

For now, just follow this simple rule:

Use a primed variable v -prime only in one of these two kinds of formulaswhere dot-dot-dot is an expression not containing primes.

We’ll relax this rule later.

[ slide 276 ]

Page 277: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

CHECKING YOUR DEFINITIONS

Let’s now check your definitions of SmallToBig and BigToSmall .

[ slide 277 ]

Page 278: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Your definitions of SmallToBig and BigToSmall

are probably not exactly like mine.

But they may still be correct.

Math provides many ways of writing the same formula.

Let’s check your definitions.

But first, let’s see how we find errors.

Your definitions are probably not exactly the same as mine.

But they may still be correct.

Math provides many ways of writing the same formula.

[ slide 278 ]

Page 279: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Your definitions of SmallToBig and BigToSmall

are probably not exactly like mine.

But they may still be correct.

Math provides many ways of writing the same formula.

Let’s check your definitions.

But first, let’s see how we find errors.

Your definitions are probably not exactly the same as mine.

But they may still be correct.

Math provides many ways of writing the same formula.

[ slide 279 ]

Page 280: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Your definitions of SmallToBig and BigToSmall

are probably not exactly like mine.

But they may still be correct.

Math provides many ways of writing the same formula.

Let’s check your definitions.

But first, let’s see how we find errors.

Your definitions are probably not exactly the same as mine.

But they may still be correct.

Math provides many ways of writing the same formula.

[ slide 280 ]

Page 281: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Your definitions of SmallToBig and BigToSmall

are probably not exactly like mine.

But they may still be correct.

Math provides many ways of writing the same formula.

Let’s check your definitions.

But first, let’s see how we find errors.

Let’s check your definitions.

But first, let’s see how we find errors.

[ slide 281 ]

Page 282: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Your definitions of SmallToBig and BigToSmall

are probably not exactly like mine.

But they may still be correct.

Math provides many ways of writing the same formula.

Let’s check your definitions.

But first, let’s see how we find errors.

Let’s check your definitions.

But first, let’s see how we find errors.

[ slide 282 ]

Page 283: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

When writing a spec, our first mistakes are found by the parser.

For example, in the Toolbox, modify the definition of SmallToBig by deletingthis plus sign.

Now save the spec.

The Toolbox runs the parser, which raises this error window.

[ slide 283 ]

Page 284: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

Modify the spec.

When writing a spec, our first mistakes are found by the parser.

For example, in the Toolbox, modify the definition of SmallToBig by deletingthis plus sign.

Now save the spec.

The Toolbox runs the parser, which raises this error window.

[ slide 284 ]

Page 285: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

Modify the spec.

When writing a spec, our first mistakes are found by the parser.

For example, in the Toolbox, modify the definition of SmallToBig by deletingthis plus sign.

Now save the spec.

The Toolbox runs the parser, which raises this error window.

[ slide 285 ]

Page 286: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

When writing a spec, our first mistakes are found by the parser.

For example, in the Toolbox, modify the definition of SmallToBig by deletingthis plus sign.

Now save the spec.

The Toolbox runs the parser, which raises this error window.

[ slide 286 ]

Page 287: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

Save the spec.

When writing a spec, our first mistakes are found by the parser.

For example, in the Toolbox, modify the definition of SmallToBig by deletingthis plus sign.

Now save the spec.

The Toolbox runs the parser, which raises this error window.

[ slide 287 ]

Page 288: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

When writing a spec, our first mistakes are found by the parser.

For example, in the Toolbox, modify the definition of SmallToBig by deletingthis plus sign.

Now save the spec.

The Toolbox runs the parser, which raises this error window.

[ slide 288 ]

Page 289: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

And it puts this error mark in the module editor.

Clicking here in the error window Highlights this part of the module andjumps to it.

[ slide 289 ]

Page 290: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

Clickhere.

And it puts this error mark in the module editor.

Clicking here in the error window Highlights this part of the module andjumps to it.

[ slide 290 ]

Page 291: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Parsing Errors

And it puts this error mark in the module editor.

Clicking here in the error window Highlights this part of the module andjumps to it.

[ slide 291 ]

Page 292: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Another common error found by parsing:

Here’s another common error found by the parser.

[ slide 292 ]

Page 293: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Another common error found by parsing:

An identifier not defined or declared.

Here’s another common error found by the parser.

An identifier not yet defined or declared. This is usually a typo.

[ slide 293 ]

Page 294: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

After there are no more parsing errors, TLC can often find errors while tryingto quote execute the spec. (We’ll see in a later video how TLC does that.)

For example, change this five to quote five. And save the spec.

Running TLC now produces

[ slide 294 ]

Page 295: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

After there are no more parsing errors, TLC can often find errors while tryingto quote execute the spec. (We’ll see in a later video how TLC does that.)

For example, change this five to quote five. And save the spec.

Running TLC now produces

[ slide 295 ]

Page 296: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

After there are no more parsing errors, TLC can often find errors while tryingto quote execute the spec. (We’ll see in a later video how TLC does that.)

For example, change this five to quote five. And save the spec.

Running TLC now produces

[ slide 296 ]

Page 297: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

After there are no more parsing errors, TLC can often find errors while tryingto quote execute the spec. (We’ll see in a later video how TLC does that.)

For example, change this five to quote five. And save the spec.

Running TLC now produces

[ slide 297 ]

Page 298: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

this error. You can read the complete error report later if you’re curious.

For now, just click here, which selects and goes to this part of the module.

[ slide 298 ]

Page 299: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

this error. You can read the complete error report later if you’re curious.

For now, just click here, which selects and goes to this part of the module.

[ slide 299 ]

Page 300: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLC “Execution Errors”

Errors TLC finds trying to “execute” the spec.

6

this error. You can read the complete error report later if you’re curious.

For now, just click here, which selects and goes to this part of the module.

[ slide 300 ]

Page 301: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Checking Your Definitions

Comment out my definitions and add your own.

Now, check your definitions of SmallToBig and BigToSmall .

First comment out my definitions by adding these comment delimiters.

And add your own definitions.

[ slide 301 ]

Page 302: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Checking Your Definitions

Comment out my definitions and add your own.

Now, check your definitions of SmallToBig and BigToSmall .

First comment out my definitions by adding these comment delimiters.

And add your own definitions.

[ slide 302 ]

Page 303: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Checking Your Definitions

Comment out my definitions and add your own.

Now, check your definitions of SmallToBig and BigToSmall .

First comment out my definitions by adding these comment delimiters.

And add your own definitions.

[ slide 303 ]

Page 304: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Checking Your Definitions

Comment out my definitions and add your own.

Now, check your definitions of SmallToBig and BigToSmall .

First comment out my definitions by adding these comment delimiters.

And add your own definitions.

[ slide 304 ]

Page 305: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Checking Your Definitions

Comment out my definitions and add your own.

Now, check your definitions of SmallToBig and BigToSmall .

First comment out my definitions by adding these comment delimiters.

And add your own definitions.

[ slide 305 ]

Page 306: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save your definitions and correct anyerrors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:

– Finds no “execution” errors.

– Finds no violation of the invariant TypeOK .

– Finds a violation of the alleged invariantbig 6= 4 .

Save your definitions and correct any errors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:– Finds no “execution” errors.– Finds no violation of the invariant TypeOK .– And finds a violation of the alleged invariant big 6= 4 .

[ slide 306 ]

Page 307: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save your definitions and correct anyerrors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:

– Finds no “execution” errors.

– Finds no violation of the invariant TypeOK .

– Finds a violation of the alleged invariantbig 6= 4 .

Save your definitions and correct any errors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:– Finds no “execution” errors.– Finds no violation of the invariant TypeOK .– And finds a violation of the alleged invariant big 6= 4 .

[ slide 307 ]

Page 308: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save your definitions and correct anyerrors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:

– Finds no “execution” errors.

– Finds no violation of the invariant TypeOK .

– Finds a violation of the alleged invariantbig 6= 4 .

Save your definitions and correct any errors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:– Finds no “execution” errors.– Finds no violation of the invariant TypeOK .– And finds a violation of the alleged invariant big 6= 4 .

[ slide 308 ]

Page 309: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save your definitions and correct anyerrors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:

– Finds no “execution” errors.

– Finds no violation of the invariant TypeOK .

– Finds a violation of the alleged invariantbig 6= 4 .

Save your definitions and correct any errors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:– Finds no “execution” errors.– Finds no violation of the invariant TypeOK .– And finds a violation of the alleged invariant big 6= 4 .

[ slide 309 ]

Page 310: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save your definitions and correct anyerrors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:

– Finds no “execution” errors.

– Finds no violation of the invariant TypeOK .

– Finds a violation of the alleged invariantbig 6= 4 .

Save your definitions and correct any errors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:– Finds no “execution” errors.– Finds no violation of the invariant TypeOK .– And finds a violation of the alleged invariant big 6= 4 .

[ slide 310 ]

Page 311: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Save your definitions and correct anyerrors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:

– Finds no “execution” errors.

– Finds no violation of the invariant TypeOK .

– Finds a violation of the alleged invariantbig 6= 4 .

Save your definitions and correct any errors the parser finds.

Run TLC.

Your definitions are probably correct if TLC:– Finds no “execution” errors.– Finds no violation of the invariant TypeOK .– And finds a violation of the alleged invariant big 6= 4 .

[ slide 311 ]

Page 312: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To be sure, go here

Uncheck this box so only TypeOK will be tested.

Run TLC again.

To be sure, go to the Invariants section of the Model Overview page and

Uncheck this box.

So only the TypeOK invariant will be tested by TLC.

And run TLC again.

[ slide 312 ]

Page 313: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To be sure, go here

Uncheck this box so only TypeOK will be tested.

Run TLC again.

To be sure, go to the Invariants section of the Model Overview page and

Uncheck this box.

So only the TypeOK invariant will be tested by TLC.

And run TLC again.

[ slide 313 ]

Page 314: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To be sure, go here

Uncheck this box so only TypeOK will be tested.

Run TLC again.

To be sure, go to the Invariants section of the Model Overview page and

Uncheck this box.

So only the TypeOK invariant will be tested by TLC.

And run TLC again.

[ slide 314 ]

Page 315: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

To be sure, go here

Uncheck this box so only TypeOK will be tested.

Run TLC again.

To be sure, go to the Invariants section of the Model Overview page and

Uncheck this box.

So only the TypeOK invariant will be tested by TLC.

And run TLC again.

[ slide 315 ]

Page 316: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

If TLC finds no error, try to find adifferent way to write the definitions.

The best way to learn is by makingmistakes.

If TLC finds no error try to find a different way to write the definitions.

The best way to learn is by making mistakes.

[ slide 316 ]

Page 317: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

If TLC finds no error, try to find adifferent way to write the definitions.

The best way to learn is by makingmistakes.

If TLC finds no error try to find a different way to write the definitions.

The best way to learn is by making mistakes.

[ slide 317 ]

Page 318: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

If TLC finds no error, try to find adifferent way to write the definitions.

The best way to learn is by makingmistakes.

If TLC finds no error try to find a different way to write the definitions.

The best way to learn is by making mistakes.

[ slide 318 ]

Page 319: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

Now that we’ve used TLC to save our heroes from certain death, it’s time toleave the glamour of Hollywood for the more romantic subject of marriageand commitment. In the next lecture, we’ll examine an algorithm that hasbeen used for many years in weddings and database systems.

[ slide 319 ]

Page 320: DIE HARD - Microsoft Azurelamport.azurewebsites.net/video/video4-script.pdf · The heroes had to put exactly 4 gallons of water in a jug. They had a 3 gallon jug, a 5 gallon jug,

TLA+ Video Course

End of Lecture 4

DIE HARD

[ slide 320 ]