255
TLA + Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION 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 9 The Alternating Bit Protocol

THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

TLA+ Video Course – Lecture 9, Part 1Leslie Lamport

THE ALTERNATING BIT PROTOCOL

THE HIGH LEVEL SPECIFICATION

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 9The Alternating Bit Protocol

Page 2: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Up until now, we have been specifying what a system may do. The main purpose ofthis lecture is to explain how to specify what a system must do. It’s based on a singleexample: the Alternating Bit Protocol — a simple algorithm for sending data across achannel that can lose messages.

In Part 1, we specify what the protocol should do. We will specify how it does it in Part2.

But before we get to the protocol, we learn about the TLA+ operators for using a veryimportant data structure: finite sequences, which programmers often call lists.[ slide 2 ]

Page 3: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

FINITE SEQUENCES

[ slide 3 ]

Page 4: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

Finite sequence is just another name for tuple .

So this tuple is a sequence of length 3.

Remember that this tuple is typed like this.

Where the angle brackets are typed double less-than and doublegreater-than.

[ slide 4 ]

Page 5: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

Finite sequence is just another name for tuple .

So this tuple is a sequence of length 3.

Remember that this tuple is typed like this.

Where the angle brackets are typed double less-than and doublegreater-than.

[ slide 5 ]

Page 6: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈 −3, “xyz ” , {0,2} 〉<< -3, "xyz", {0,2} >>

is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

Finite sequence is just another name for tuple .

So this tuple is a sequence of length 3.

Remember that this tuple is typed like this.

Where the angle brackets are typed double less-than and doublegreater-than.

[ slide 6 ]

Page 7: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈 −3, “xyz ” , {0,2} 〉<< -3, "xyz", {0,2} >>

is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

Finite sequence is just another name for tuple .

So this tuple is a sequence of length 3.

Remember that this tuple is typed like this.

Where the angle brackets are typed double less-than and doublegreater-than.

[ slide 7 ]

Page 8: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈 −3, “xyz ” , {0,2} 〉<< -3, "xyz", {0,2} >>

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

Finite sequence is just another name for tuple .

So this tuple is a sequence of length 3.

Remember that this tuple is typed like this.

Where the angle brackets are typed double less-than and doublegreater-than.

[ slide 8 ]

Page 9: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

Finite sequence is just another name for tuple .

So this tuple is a sequence of length 3.

Remember that this tuple is typed like this.

Where the angle brackets are typed double less-than and doublegreater-than.

[ slide 9 ]

Page 10: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 10 ]

Page 11: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 11 ]

Page 12: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 12 ]

Page 13: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 13 ]

Page 14: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 14 ]

Page 15: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 15 ]

Page 16: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 16 ]

Page 17: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Finite sequence is another name for tuple .

〈−3, “xyz ”, {0,2} 〉 is a sequence of length 3.

A sequence of length N is a function with domain 1 . .N .

〈 − 3, “xyz ”, {0,2} 〉[1] = −3

〈 − 3, “xyz ”, {0,2} 〉[2] = “xyz ”

〈 − 3, “xyz ”, {0,2} 〉[3] = {0,2}

A sequence of length N is a function whose domain is the set of integersfrom 1 through N .

This sequence of length 3 applied to the number one equals its first element.

The sequence applied to the number two equals its second element.

And applied to the number three equals its third element.

[ slide 17 ]

Page 18: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The sequence 〈1, 4, 9, . . . , N 2〉 is the function such that

〈1, 4, 9, . . . , N 2〉 [i ] = i2

for all i in 1 . .N .

It is written [ i ∈ 1 . .N 7→ i2 ] .

The sequence of the squares of the first N positive integers is the functionwhichwhen applied to the number i , equals i squaredfor all i in its domain, the integers from 1 through N .

That function is usually written this waywhere the exponentiation operator is represented by the caret character.

[ slide 18 ]

Page 19: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The sequence 〈1, 4, 9, . . . , N 2〉 is the function such that

〈1, 4, 9, . . . , N 2〉 [i ] = i2

for all i in 1 . .N .

It is written [ i ∈ 1 . .N 7→ i2 ] .

The sequence of the squares of the first N positive integers is the functionwhichwhen applied to the number i , equals i squaredfor all i in its domain, the integers from 1 through N .

That function is usually written this waywhere the exponentiation operator is represented by the caret character.

[ slide 19 ]

Page 20: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The sequence 〈1, 4, 9, . . . , N 2〉 is the function such that

〈1, 4, 9, . . . , N 2〉 [i ] = i2

for all i in 1 . .N .

It is written [ i ∈ 1 . .N 7→ i2 ] .

The sequence of the squares of the first N positive integers is the functionwhichwhen applied to the number i , equals i squaredfor all i in its domain, the integers from 1 through N .

That function is usually written this waywhere the exponentiation operator is represented by the caret character.

[ slide 20 ]

Page 21: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The sequence 〈1, 4, 9, . . . , N 2〉 is the function such that

〈1, 4, 9, . . . , N 2〉 [i ] = i2

for all i in 1 . .N .

It is written [ i ∈ 1 . .N 7→ i2 ] .

The sequence of the squares of the first N positive integers is the functionwhichwhen applied to the number i , equals i squaredfor all i in its domain, the integers from 1 through N .

That function is usually written this waywhere the exponentiation operator is represented by the caret character.

[ slide 21 ]

Page 22: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The sequence 〈1, 4, 9, . . . , N 2〉 is the function such that

〈1, 4, 9, . . . , N 2〉 [i ] = i2

for all i in 1 . .N .

It is written [ i ∈ 1 . .N 7→ i2 ] .

typed i^2

The sequence of the squares of the first N positive integers is the functionwhichwhen applied to the number i , equals i squaredfor all i in its domain, the integers from 1 through N .

That function is usually written this waywhere the exponentiation operator is represented by the caret character.

[ slide 22 ]

Page 23: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

Append(seq , e)∆= seq ◦ 〈e〉

The standard Sequences module defines some useful operators on finitesequences.

The tail of a non-empty sequence equals the sequence obtained 1bychopping off its first element

And since it would be funny to have a tail without a head, we call the firstelement its head.

[ slide 23 ]

Page 24: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Defines useful operators.

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

Append(seq , e)∆= seq ◦ 〈e〉

The standard Sequences module defines some useful operators on finitesequences.

The tail of a non-empty sequence equals the sequence obtained 1bychopping off its first element

And since it would be funny to have a tail without a head, we call the firstelement its head.

[ slide 24 ]

Page 25: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

Append(seq , e)∆= seq ◦ 〈e〉

The standard Sequences module defines some useful operators on finitesequences.

The tail of a non-empty sequence equals the sequence obtained 1bychopping off its first element

And since it would be funny to have a tail without a head, we call the firstelement its head.

[ slide 25 ]

Page 26: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

Append(seq , e)∆= seq ◦ 〈e〉

The standard Sequences module defines some useful operators on finitesequences.

The tail of a non-empty sequence equals the sequence obtained 1bychopping off its first element

And since it would be funny to have a tail without a head, we call the firstelement its head.

[ slide 26 ]

Page 27: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

Append(seq , e)∆= seq ◦ 〈e〉

The concatenation operator which we type backslash lower-case Oh,concatenates two sequences as in this example.

Any non-empty sequence is the concatenation of the one-element sequencecontaining only its head, with its tail.

The append operator appends an element to the end of a sequence.

[ slide 27 ]

Page 28: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

\o

Append(seq , e)∆= seq ◦ 〈e〉

The concatenation operator which we type backslash lower-case Oh,concatenates two sequences as in this example.

Any non-empty sequence is the concatenation of the one-element sequencecontaining only its head, with its tail.

The append operator appends an element to the end of a sequence.

[ slide 28 ]

Page 29: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

〈3, 2, 1〉 ◦ 〈“a”, “b”〉 = 〈3, 2, 1, “a”, “b”〉

Append(seq , e)∆= seq ◦ 〈e〉

The concatenation operator which we type backslash lower-case Oh,concatenates two sequences as in this example.

Any non-empty sequence is the concatenation of the one-element sequencecontaining only its head, with its tail.

The append operator appends an element to the end of a sequence.

[ slide 29 ]

Page 30: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

If seq 6= 〈 〉 then seq = 〈Head(seq)〉 ◦ Tail(seq)

Append(seq , e)∆= seq ◦ 〈e〉

The concatenation operator which we type backslash lower-case Oh,concatenates two sequences as in this example.

Any non-empty sequence is the concatenation of the one-element sequencecontaining only its head, with its tail.

The append operator appends an element to the end of a sequence.

[ slide 30 ]

Page 31: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Sequences Module

Tail( 〈s1, . . . , sn〉) equals 〈s2, . . . , sn〉 .

Head(seq)∆= seq [1]

◦ (concatenation)

Append(seq , e)∆= seq ◦ 〈e〉

The concatenation operator which we type backslash lower-case Oh,concatenates two sequences as in this example.

Any non-empty sequence is the concatenation of the one-element sequencecontaining only its head, with its tail.

The append operator appends an element to the end of a sequence.

[ slide 31 ]

Page 32: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Len(seq) equals the length of sequence seq .

Seq(S ) is the set of all sequences with elements in S .

The operator L-E-N applied to a sequence equals the sequence’s length.

Note that the domain of a sequence is the set of integers from 1 to thesequence’s length.

Note also that one dot-dot zero is the empty set, which is the domain of theempty sequence.

[ slide 32 ]

Page 33: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Len(seq) equals the length of sequence seq .

The domain of seq is 1 . .Len(seq) .

Seq(S ) is the set of all sequences with elements in S .

The operator L-E-N applied to a sequence equals the sequence’s length.

Note that the domain of a sequence is the set of integers from 1 to thesequence’s length.

Note also that one dot-dot zero is the empty set, which is the domain of theempty sequence.

[ slide 33 ]

Page 34: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Len(seq) equals the length of sequence seq .

The domain of seq is 1 . .Len(seq) .

1 . .0 = {} , which is the domain of 〈 〉 .

Seq(S ) is the set of all sequences with elements in S .

The operator L-E-N applied to a sequence equals the sequence’s length.

Note that the domain of a sequence is the set of integers from 1 to thesequence’s length.

Note also that one dot-dot zero is the empty set, which is the domain of theempty sequence.

[ slide 34 ]

Page 35: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Len(seq) equals the length of sequence seq .

Seq(S ) is the set of all sequences with elements in S .

The S-E-Q operator applied to a set equals the set of all finite sequencesformed from the elements of that set.

For example, S-E-Q applied to the set containing the single element 3 equalsthis infinite set of sequences.[ slide 35 ]

Page 36: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Len(seq) equals the length of sequence seq .

Seq(S ) is the set of all sequences with elements in S .

Seq({3}) = {〈 〉, 〈3〉, 〈3,3〉, 〈3,3,3〉, . . .} .

The S-E-Q operator applied to a set equals the set of all finite sequencesformed from the elements of that set.

For example, S-E-Q applied to the set containing the single element 3 equalsthis infinite set of sequences.[ slide 36 ]

Page 37: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Let’s define Remove(i , seq) to be the sequenceobtained by removing the i th element from thesequence seq .

Len(Remove(i , seq)) = Len(seq)− 1 , so

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

Let’s check this.

For later use, let’s now define the Remove operator so Remove of i , seek isthe sequence obtained by removing the i th element from the sequence seek .

The length of Remove of i , seek should be one less than the length of seek .so Remove of i , seek should be defined like this to be a function whosedomain is the set of integers from one to the length of seek minus one.

[ slide 37 ]

Page 38: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Let’s define Remove(i , seq) to be the sequenceobtained by removing the i th element from thesequence seq .

Len(Remove(i , seq)) = Len(seq)− 1 , so

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

Let’s check this.

For later use, let’s now define the Remove operator so Remove of i , seek isthe sequence obtained by removing the i th element from the sequence seek .

The length of Remove of i , seek should be one less than the length of seek .so Remove of i , seek should be defined like this to be a function whosedomain is the set of integers from one to the length of seek minus one.

[ slide 38 ]

Page 39: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Let’s define Remove(i , seq) to be the sequenceobtained by removing the i th element from thesequence seq .

Len(Remove(i , seq)) = Len(seq)− 1 , so

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

. . . ]

Let’s check this.

For later use, let’s now define the Remove operator so Remove of i , seek isthe sequence obtained by removing the i th element from the sequence seek .

The length of Remove of i , seek should be one less than the length of seek .so Remove of i , seek should be defined like this to be a function whosedomain is the set of integers from one to the length of seek minus one.

[ slide 39 ]

Page 40: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Let’s define Remove(i , seq) to be the sequenceobtained by removing the i th element from thesequence seq .

Len(Remove(i , seq)) = Len(seq)− 1 , so

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

. . . ]

Let’s check this.

We just have to fill in the dot-dot-dot.

A little thought shows that the definition should be this.

Well, a little thought when you’re more used to writing specs. It might be a lotof thought now.

So we should check this definition. Here’s how.

[ slide 40 ]

Page 41: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Let’s define Remove(i , seq) to be the sequenceobtained by removing the i th element from thesequence seq .

Len(Remove(i , seq)) = Len(seq)− 1 , so

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

IF j < i THEN seq [j ]

ELSE seq [j + 1] ]

Let’s check this.

We just have to fill in the dot-dot-dot.

A little thought shows that the definition should be this.

Well, a little thought when you’re more used to writing specs. It might be a lotof thought now.

So we should check this definition. Here’s how.

[ slide 41 ]

Page 42: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Let’s define Remove(i , seq) to be the sequenceobtained by removing the i th element from thesequence seq .

Len(Remove(i , seq)) = Len(seq)− 1 , so

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

IF j < i THEN seq [j ]

ELSE seq [j + 1] ]

Let’s check this.

We just have to fill in the dot-dot-dot.

A little thought shows that the definition should be this.

Well, a little thought when you’re more used to writing specs. It might be a lotof thought now.

So we should check this definition. Here’s how.

[ slide 42 ]

Page 43: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Create a new spec with this body, whichyou can copy from the Web page:

EXTENDS Integers,Sequences

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

IF j < i THEN seq[j ] ELSE seq[j + 1] ]

Create a new model.

Create a new spec with this body, whichyou can copy from the Web page.

Now create a new model.

[ slide 43 ]

Page 44: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Create a new spec with this body, whichyou can copy from the Web page:

EXTENDS Integers,Sequences

Remove(i , seq)∆= [ j ∈ 1 . . (Len(seq)− 1) 7→

IF j < i THEN seq[j ] ELSE seq[j + 1] ]

Create a new model.

Create a new spec with this body, whichyou can copy from the Web page.

Now create a new model.

[ slide 44 ]

Page 45: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Model Overview page will show

The model’s Model Overview page will showthat there are no behaviors to be checked.

(TLC can still check assumptions.)

[ slide 45 ]

Page 46: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Model Overview page will show

The model’s Model Overview page will showthat there are no behaviors to be checked.

(TLC can still check assumptions.)

[ slide 46 ]

Page 47: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

On the Model Checking Results page

Enter an expression to check. TLC computes its value.

Run TLC on the model.

On the Model Checking Results page Enter an expression to check, such asthis one.

Run TLC on the model.

TLC will compute the value of the expression.in this case checking that Remove has the correct value for these arguments.

[ slide 47 ]

Page 48: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

On the Model Checking Results page

Remove(3, <<1, 2, 3, 4>>)

Enter an expression to check. TLC computes its value.

Run TLC on the model.

On the Model Checking Results page Enter an expression to check, such asthis one.

Run TLC on the model.

TLC will compute the value of the expression.in this case checking that Remove has the correct value for these arguments.

[ slide 48 ]

Page 49: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

On the Model Checking Results page

Remove(3, <<1, 2, 3, 4>>)

Enter an expression to check. TLC computes its value.

Run TLC on the model.

On the Model Checking Results page Enter an expression to check, such asthis one.

Run TLC on the model.

TLC will compute the value of the expression.in this case checking that Remove has the correct value for these arguments.

[ slide 49 ]

Page 50: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

On the Model Checking Results page

Remove(3, <<1, 2, 3, 4>>) <<1, 2, 4>>

Enter an expression to check. TLC computes its value.

Run TLC on the model.

On the Model Checking Results page Enter an expression to check, such asthis one.

Run TLC on the model.

TLC will compute the value of the expression.in this case checking that Remove has the correct value for these arguments.

[ slide 50 ]

Page 51: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

On the Model Checking Results page

Remove(3, <<1, 2, 3, 4>>) <<1, 2, 4>>

Enter an expression to check. TLC computes its value.

Run TLC on the model.

On the Model Checking Results page Enter an expression to check, such asthis one.

Run TLC on the model.

TLC will compute the value of the expression.in this case checking that Remove has the correct value for these arguments.

[ slide 51 ]

Page 52: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

On the Model Checking Results pageYou can evaluate a constant expression onany model of any spec.

You can evaluate a constant expression on any model, with or without abehavioral spec.

[ slide 52 ]

Page 53: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T =

The Cartesian Product

For any sets S and T their cartesian product S cross T equals the set of allpairs a, b with a in S and b in T .

That set can also be written like this.

The cross operator is typed backslash upper-case X.

[ slide 53 ]

Page 54: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T = the set of all 〈a, b〉 witha ∈ S and b ∈ T .

The Cartesian Product

For any sets S and T their cartesian product S cross T equals the set of allpairs a, b with a in S and b in T .

That set can also be written like this.

The cross operator is typed backslash upper-case X.

[ slide 54 ]

Page 55: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}

The Cartesian Product

For any sets S and T their cartesian product S cross T equals the set of allpairs a, b with a in S and b in T .

That set can also be written like this.

The cross operator is typed backslash upper-case X.

[ slide 55 ]

Page 56: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}ASCII: \X

The Cartesian Product

For any sets S and T their cartesian product S cross T equals the set of allpairs a, b with a in S and b in T .

That set can also be written like this.

The cross operator is typed backslash upper-case X.

[ slide 56 ]

Page 57: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}

Let TLC compute (1 . .3)× {“a”, “b”}.

It’s parsed as 1 . . (3× {“a”, “b”}) .

Stop the video and let TLC compute this 6-element set.

Now see what happens if you remove the parentheses.

You get an error because this is how that expression is parsed.

[ slide 57 ]

Page 58: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}

Let TLC compute (1 . .3)× {“a”, “b”}.

It’s parsed as 1 . . (3× {“a”, “b”}) .

Stop the video and let TLC compute this 6-element set.

Now see what happens if you remove the parentheses.

You get an error because this is how that expression is parsed.

[ slide 58 ]

Page 59: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S and T

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}

Let TLC compute (1 . .3)× {“a”, “b”}.

It’s parsed as 1 . . (3× {“a”, “b”}) .

Stop the video and let TLC compute this 6-element set.

Now see what happens if you remove the parentheses.

You get an error because this is how that expression is parsed.

[ slide 59 ]

Page 60: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S , T , and U

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}

S × T × U = {〈a, b, c〉 : a ∈ S , b ∈ T c ∈ U }...

The cross product of three sets is the obvious set of triples.

And so on for the cross product of any number of sets.

[ slide 60 ]

Page 61: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The Cartesian Product

For any sets S , T , and U

S ×T = {〈a, b〉 : a ∈ S , b ∈ T}

S × T × U = {〈a, b, c〉 : a ∈ S , b ∈ T c ∈ U }...

The cross product of three sets is the obvious set of triples.

And so on for the cross product of any number of sets.

[ slide 61 ]

Page 62: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

WHAT THE PROTOCOLSHOULD ACCOMPLISH

[ slide 62 ]

Page 63: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

In the Alternating Bit protocolAB protocol a sender A sendsa sequence of

to a receiver B .

Here’s an obvious way to represent this.

In the Alternating Bit protocol We abbreviate “alternating bit” as A-B.

In the AB protocol, a sender A sends a sequence of data items to areceiver B .

Let’s suppose for now that those data items are strings.

Here’s an obvious way to represent this.

[ slide 63 ]

Page 64: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

In the AB protocol a sender A sends a sequence ofto a receiver B .

Here’s an obvious way to represent this.

In the Alternating Bit protocol We abbreviate “alternating bit” as A-B.

In the AB protocol, a sender A sends a sequence of data items to areceiver B .

Let’s suppose for now that those data items are strings.

Here’s an obvious way to represent this.

[ slide 64 ]

Page 65: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

In the AB protocol a sender A sends a sequence ofdata items to a receiver B .

Here’s an obvious way to represent this.

In the Alternating Bit protocol We abbreviate “alternating bit” as A-B.

In the AB protocol, a sender A sends a sequence of data items to areceiver B .

Let’s suppose for now that those data items are strings.

Here’s an obvious way to represent this.

[ slide 65 ]

Page 66: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

In the AB protocol a sender A sends a sequence ofstrings to a receiver B .

Here’s an obvious way to represent this.

In the Alternating Bit protocol We abbreviate “alternating bit” as A-B.

In the AB protocol, a sender A sends a sequence of data items to areceiver B .

Let’s suppose for now that those data items are strings.

Here’s an obvious way to represent this.

[ slide 66 ]

Page 67: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

In the AB protocol a sender A sends a sequence ofstrings to a receiver B .

Here’s an obvious way to represent this.

In the Alternating Bit protocol We abbreviate “alternating bit” as A-B.

In the AB protocol, a sender A sends a sequence of data items to areceiver B .

Let’s suppose for now that those data items are strings.

Here’s an obvious way to represent this.

[ slide 67 ]

Page 68: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

BVar :

B

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

The states of A and B are represented by two variables, AVar and BVar .

They’re initially set to some default value, say the empty string.

If A wants to send a string, say the string Fred,it sets AVar to that value.

B must eventually receive that string

[ slide 68 ]

Page 69: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“ ” BVar :

B

“ ”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

The states of A and B are represented by two variables, AVar and BVar .

They’re initially set to some default value, say the empty string.

If A wants to send a string, say the string Fred,it sets AVar to that value.

B must eventually receive that string

[ slide 69 ]

Page 70: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Fred ” BVar :

B

“ ”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

The states of A and B are represented by two variables, AVar and BVar .

They’re initially set to some default value, say the empty string.

If A wants to send a string, say the string Fred,it sets AVar to that value.

B must eventually receive that string

[ slide 70 ]

Page 71: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Fred ” BVar :

B

“Fred ”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 71 ]

Page 72: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Mary” BVar :

B

“Fred ”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 72 ]

Page 73: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Mary” BVar :

B

“Mary”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 73 ]

Page 74: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Mary”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 74 ]

Page 75: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 75 ]

Page 76: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ann” BVar :

B

“Ted ”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 76 ]

Page 77: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ann” BVar :

B

“Ann”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

by setting BVar equal to it.

A chooses a new value, say Mary

which it sends and B receives.

and so on.

[ slide 77 ]

Page 78: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ann” BVar :

B

“Ann”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

What sequence of values was sent?

Obviously, the sequence Fred, Mary, Ted, and Ann.

No, it was actually this sequence.

Didn’t you see AVar change from Mary to Mary , and BVar do the samething?

[ slide 78 ]

Page 79: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ann” BVar :

B

“Ann”

What sequence of values was sent?

“Fred ”, “Mary”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

What sequence of values was sent?

Obviously, the sequence Fred, Mary, Ted, and Ann.

No, it was actually this sequence.

Didn’t you see AVar change from Mary to Mary , and BVar do the samething?

[ slide 79 ]

Page 80: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ann” BVar :

B

“Ann”

What sequence of values was sent?

“Fred ”, “Mary”, “Mary”, “Ted ”, “Ted ”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

What sequence of values was sent?

Obviously, the sequence Fred, Mary, Ted, and Ann.

No, it was actually this sequence.

Didn’t you see AVar change from Mary to Mary , and BVar do the samething?

[ slide 80 ]

Page 81: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Mary” BVar :

B

“Mary”

What sequence of values was sent?

“Fred ”, “Mary”, “Mary”, “Ted ”, “Ted ”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

What sequence of values was sent?

Obviously, the sequence Fred, Mary, Ted, and Ann.

No, it was actually this sequence.

Didn’t you see AVar change from Mary to Mary , and BVar do the samething?

[ slide 81 ]

Page 82: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

What sequence of values was sent?

“Fred ”, “Mary”, “Mary”, “Ted ”, “Ted ”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

And didn’t you see them changing from Ted to Ted twice?

Of course not. A value can’t have been sent if nothing changed.

How can we let the same value be sent twice in a row?

By adding something to the state that can change when the value is sent forthe second time.

[ slide 82 ]

Page 83: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

What sequence of values was sent?

“Fred ”, “Mary”, “Mary”, “Ted ”, “Ted ”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

And didn’t you see them changing from Ted to Ted twice?

Of course not. A value can’t have been sent if nothing changed.

How can we let the same value be sent twice in a row?

By adding something to the state that can change when the value is sent forthe second time.

[ slide 83 ]

Page 84: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

What sequence of values was sent?

“Fred ”, “Mary”, “Mary”, “Ted ”, “Ted ”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

And didn’t you see them changing from Ted to Ted twice?

Of course not. A value can’t have been sent if nothing changed.

How can we let the same value be sent twice in a row?

By adding something to the state that can change when the value is sent forthe second time.

[ slide 84 ]

Page 85: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

What sequence of values was sent?

“Fred ”, “Mary”, “Mary”, “Ted ”, “Ted ”, “Ted ”, “Ann”

How can this sequence of values be sent?

With additional state that can change.

And didn’t you see them changing from Ted to Ted twice?

Of course not. A value can’t have been sent if nothing changed.

How can we let the same value be sent twice in a row?

By adding something to the state that can change when the value is sent forthe second time.

[ slide 85 ]

Page 86: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 86 ]

Page 87: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

clock :

AVar :

A

“Ted ” BVar :

B

“Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 87 ]

Page 88: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

clock :

AVar :

A

“Ted ” BVar :

B

“Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 88 ]

Page 89: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

“Ted ” BVar :

B

“Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 89 ]

Page 90: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Ted ”, 1〉

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 90 ]

Page 91: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Ted ”, 1〉

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 91 ]

Page 92: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Ted ”, 1〉

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 92 ]

Page 93: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ann”, 0〉 BVar :

B

〈“Ted ”, 1〉

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 93 ]

Page 94: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

BVar :

B

“Fred ”, “Mary”, “Mary” , “Ted ” , “Ted ” , “Ted ” , “Ann”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 94 ]

Page 95: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“ ”, 1〉 BVar :

B

〈“ ”, 1〉

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 95 ]

Page 96: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Fred ”, 0〉 BVar :

B

〈“ ”, 1〉

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 96 ]

Page 97: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Fred ”, 0〉 BVar :

B

〈“Fred ”, 0〉

“Fred ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 97 ]

Page 98: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Mary”, 1〉 BVar :

B

〈“Fred ”, 0〉

“Fred ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 98 ]

Page 99: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Mary”, 1〉 BVar :

B

〈“Mary”, 1〉

“Fred ”, “Mary”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 99 ]

Page 100: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Mary”, 0〉 BVar :

B

〈“Mary”, 1〉

“Fred ”, “Mary”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 100 ]

Page 101: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Mary”, 0〉 BVar :

B

〈“Mary”, 0〉

“Fred ”, “Mary”, “Mary”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 101 ]

Page 102: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Mary”, 0〉

“Fred ”, “Mary”, “Mary”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 102 ]

Page 103: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Ted ”, 1〉

“Fred ”, “Mary”, “Mary” , “Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 103 ]

Page 104: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 0〉 BVar :

B

〈“Ted ”, 1〉

“Fred ”, “Mary”, “Mary” , “Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 104 ]

Page 105: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 0〉 BVar :

B

〈“Ted ”, 0〉

“Fred ”, “Mary”, “Mary” , “Ted ” , “Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 105 ]

Page 106: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Ted ”, 0〉

“Fred ”, “Mary”, “Mary” , “Ted ” , “Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 106 ]

Page 107: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ted ”, 1〉 BVar :

B

〈“Ted ”, 1〉

“Fred ”, “Mary”, “Mary” , “Ted ” , “Ted ” , “Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 107 ]

Page 108: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ann”, 0〉 BVar :

B

〈“Ted ”, 1〉

“Fred ”, “Mary”, “Mary” , “Ted ” , “Ted ” , “Ted ”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 108 ]

Page 109: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar :

A

〈“Ann”, 0〉 BVar :

B

〈“Ann”, 0〉

“Fred ”, “Mary”, “Mary” , “Ted ” , “Ted ” , “Ted ” , “Ann”

We could add a variable clock And let the value in AVar be sent again whenthe value of clock changes. But we’ll take a different approach

We’ll let the values of AVar and BVar be ordered pairs, the first element ofwhich is the value being sent and the second element is a one-bit value thatis changed when a value is chosen. So we can send this sequence of valuesLike this [15 × (1 per second) pause ]

[ slide 109 ]

Page 110: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

THE HIGH LEVEL SPEC

[ slide 110 ]

Page 111: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The spec of what the AB protocol is supposed to accomplish is in a modulenamed ABSpec.

As usual, it extends the Integers module.

And it declares the constant Data, which is the set of all values that can betransmitted.

[ slide 111 ]

Page 112: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The spec of what the AB protocol is supposed to accomplish is in a modulenamed ABSpec.

As usual, it extends the Integers module.

And it declares the constant Data, which is the set of all values that can betransmitted.

[ slide 112 ]

Page 113: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The set of values that can be transmitted.

The spec of what the AB protocol is supposed to accomplish is in a modulenamed ABSpec.

As usual, it extends the Integers module.

And it declares the constant Data, which is the set of all values that can betransmitted.

[ slide 113 ]

Page 114: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We declare the spec’s two variables and the type correctness invariantasserting that both variables are pairs whose first element is in the set Data,and whose second element is either zero or one.

It’s convenient to define vars to be the tuple of all variables.

[ slide 114 ]

Page 115: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar and BVar are〈data, 0 or 1〉 pairs.

We declare the spec’s two variables and the type correctness invariantasserting that both variables are pairs whose first element is in the set Data,and whose second element is either zero or one.

It’s convenient to define vars to be the tuple of all variables.

[ slide 115 ]

Page 116: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We declare the spec’s two variables and the type correctness invariantasserting that both variables are pairs whose first element is in the set Data,and whose second element is either zero or one.

It’s convenient to define vars to be the tuple of all variables.

[ slide 116 ]

Page 117: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The initial-state formula asserts thatAVar can equal any pair whose first element is in Data and whose secondelement is 1.

And BVar must equal AVar .

[ slide 117 ]

Page 118: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

AVar can equal 〈any element of Data, 1〉 .

The initial-state formula asserts thatAVar can equal any pair whose first element is in Data and whose secondelement is 1.

And BVar must equal AVar .

[ slide 118 ]

Page 119: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The initial-state formula asserts thatAVar can equal any pair whose first element is in Data and whose secondelement is 1.

And BVar must equal AVar .

[ slide 119 ]

Page 120: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A chooses a new value to send.

We’re going to define A to be the action in which the sender A chooses anew value to send.

And we’re going to define B to be the action in which the receiver B receivesa value.

The next-state action permits an A step or a B step.

[ slide 120 ]

Page 121: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

B receives a value.

We’re going to define A to be the action in which the sender A chooses anew value to send.

And we’re going to define B to be the action in which the receiver B receivesa value.

The next-state action permits an A step or a B step.

[ slide 121 ]

Page 122: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We’re going to define A to be the action in which the sender A chooses anew value to send.

And we’re going to define B to be the action in which the receiver B receivesa value.

The next-state action permits an A step or a B step.

[ slide 122 ]

Page 123: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

And here’s the complete spec.

Remember that vars was defined to be the tuple of all variables.

[ slide 123 ]

Page 124: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

And here’s the complete spec.

Remember that vars was defined to be the tuple of all variables.

[ slide 124 ]

Page 125: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Now for the definition of action A.

The action can be taken when AVar equals BVar .

The new value of AVar is a pair that can have any data value as its firstcomponent and whose second component is the complement of AVar ’soriginal second component.

[ slide 125 ]

Page 126: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Now for the definition of action A.

The action can be taken when AVar equals BVar .

The new value of AVar is a pair that can have any data value as its firstcomponent and whose second component is the complement of AVar ’soriginal second component.

[ slide 126 ]

Page 127: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Now for the definition of action A.

The action can be taken when AVar equals BVar .

The new value of AVar is a pair that can have any data value as its firstcomponent and whose second component is the complement of AVar ’soriginal second component.

[ slide 127 ]

Page 128: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

the complement of AVar [2]

Now for the definition of action A.

The action can be taken when AVar equals BVar .

The new value of AVar is a pair that can have any data value as its firstcomponent and whose second component is the complement of AVar ’soriginal second component.

[ slide 128 ]

Page 129: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

the complement of AVar [2]IF AVar [2] = 0 THEN 1

ELSE 0

A programmer might write that complement this way.

A mathematician might write it this way where percent is the modulusoperator used in many programming languages.

TLC will show you how it’s defined for negative arguments.

[ slide 129 ]

Page 130: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

the complement of AVar [2]IF AVar [2] = 0 THEN 1

ELSE 0(AVar [2] + 1) % 2

A programmer might write that complement this way.

A mathematician might write it this way where percent is the modulusoperator used in many programming languages.

TLC will show you how it’s defined for negative arguments.

[ slide 130 ]

Page 131: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

the complement of AVar [2]IF AVar [2] = 0 THEN 1

ELSE 0(AVar [2] + 1) % 2

A programmer might write that complement this way.

A mathematician might write it this way where percent is the modulusoperator used in many programming languages.

TLC will show you how it’s defined for negative arguments.

[ slide 131 ]

Page 132: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

the complement of AVar [2]

We’ll write it like this, the way a bright child might.

The action leaves BVar unchanged.

[ slide 132 ]

Page 133: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We’ll write it like this, the way a bright child might.

The action leaves BVar unchanged.

[ slide 133 ]

Page 134: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We’ll write it like this, the way a bright child might.

The action leaves BVar unchanged.

[ slide 134 ]

Page 135: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We now define action B , in which a message is received.

A B step can be taken when the values of AVar and BVar are unequal.

The step sets the value of BVar to that of AVar

And it leaves AVar unchanged.

[ slide 135 ]

Page 136: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We now define action B , in which a message is received.

A B step can be taken when the values of AVar and BVar are unequal.

The step sets the value of BVar to that of AVar

And it leaves AVar unchanged.

[ slide 136 ]

Page 137: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We now define action B , in which a message is received.

A B step can be taken when the values of AVar and BVar are unequal.

The step sets the value of BVar to that of AVar

And it leaves AVar unchanged.

[ slide 137 ]

Page 138: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

We now define action B , in which a message is received.

A B step can be taken when the values of AVar and BVar are unequal.

The step sets the value of BVar to that of AVar

And it leaves AVar unchanged.

[ slide 138 ]

Page 139: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

This completes the definition of the specification Spec.

[ slide 139 ]

Page 140: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

– Stop the video.

– Download ABSpec.

– Open it in the Toolbox.

– Create a model that substitutes asmall set of model values for Data .

– Run TLC on the model to checkinvariance of TypeOK .

Stop the video now to download ABSpec and open it in the Toolbox.

Create a model that substitutes a small set of model values, perhapscontaining 3 values, for Data .

And run TLC on the model to check that TypeOK is an invariant.

[ slide 140 ]

Page 141: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

– Stop the video.

– Download ABSpec.

– Open it in the Toolbox.

– Create a model that substitutes asmall set of model values for Data .

– Run TLC on the model to checkinvariance of TypeOK .

Stop the video now to download ABSpec and open it in the Toolbox.

Create a model that substitutes a small set of model values, perhapscontaining 3 values, for Data .

And run TLC on the model to check that TypeOK is an invariant.

[ slide 141 ]

Page 142: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

– Stop the video.

– Download ABSpec.

– Open it in the Toolbox.

– Create a model that substitutes asmall set of model values for Data .

– Run TLC on the model to checkinvariance of TypeOK .

Stop the video now to download ABSpec and open it in the Toolbox.

Create a model that substitutes a small set of model values, perhapscontaining 3 values, for Data .

And run TLC on the model to check that TypeOK is an invariant.

[ slide 142 ]

Page 143: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Type correctness doesn’t meanthe spec is correct.

To find errors, check that formulaswhich should be invariants are.

Here’s one such formula defined in ABSpec :

Convince yourself that it should be an invariantand have TLC check that it is.

Type correctness doesn’t mean that a specification is correct.

To find errors, we should check that formulas which should be invariantsactually are invariants.

Here’s one such formula defined in the ABSpec module.

[ slide 143 ]

Page 144: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Type correctness doesn’t meanthe spec is correct.

To find errors, check that formulaswhich should be invariants are.

Here’s one such formula defined in ABSpec :

Convince yourself that it should be an invariantand have TLC check that it is.

Type correctness doesn’t mean that a specification is correct.

To find errors, we should check that formulas which should be invariantsactually are invariants.

Here’s one such formula defined in the ABSpec module.

[ slide 144 ]

Page 145: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Type correctness doesn’t meanthe spec is correct.

To find errors, check that formulaswhich should be invariants are.

Here’s one such formula defined in ABSpec :

Convince yourself that it should be an invariantand have TLC check that it is.

Type correctness doesn’t mean that a specification is correct.

To find errors, we should check that formulas which should be invariantsactually are invariants.

Here’s one such formula defined in the ABSpec module.

[ slide 145 ]

Page 146: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Type correctness doesn’t meanthe spec is correct.

To find errors, check that formulaswhich should be invariants are.

Here’s one such formula defined in ABSpec :

Convince yourself that it should be an invariantand have TLC check that it is.

Convince yourself that it should be an invariant and have TLC check that itactually is.

[ slide 146 ]

Page 147: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Formula Spec asserts what may happen.

We now specify what must happen.

Exactly what do may and must mean?

Like all the specifications we’ve written so far, formula Spec asserts only whatmay happen.

We will now specify what must happen.

But first, we look at exactly what may and must mean.

[ slide 147 ]

Page 148: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Formula Spec asserts what may happen.

We now specify what must happen.

Exactly what do may and must mean?

Like all the specifications we’ve written so far, formula Spec asserts only whatmay happen.

We will now specify what must happen.

But first, we look at exactly what may and must mean.

[ slide 148 ]

Page 149: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Formula Spec asserts what may happen.

We now specify what must happen.

Exactly what do may and must mean?

Like all the specifications we’ve written so far, formula Spec asserts only whatmay happen.

We will now specify what must happen.

But first, we look at exactly what may and must mean.

[ slide 149 ]

Page 150: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

SAFETY AND LIVENESS

[ slide 150 ]

Page 151: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

A safety formula is a temporal formula that asserts only what may happen.

More precisely, it’s a temporal formula that if a behavior violates it – meaningthat if the formula is false on the behavior, then that violation occurs at someparticular point in the behavior.

And nothing in the behavior past that point can prevent the violation.

[ slide 151 ]

Page 152: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

A safety formula is a temporal formula that asserts only what may happen.

More precisely, it’s a temporal formula that if a behavior violates it – meaningthat if the formula is false on the behavior, then that violation occurs at someparticular point in the behavior.

And nothing in the behavior past that point can prevent the violation.

[ slide 152 ]

Page 153: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

A safety formula is a temporal formula that asserts only what may happen.

More precisely, it’s a temporal formula that if a behavior violates it – meaningthat if the formula is false on the behavior, then that violation occurs at someparticular point in the behavior.

And nothing in the behavior past that point can prevent the violation.

[ slide 153 ]

Page 154: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

A safety formula is a temporal formula that asserts only what may happen.

More precisely, it’s a temporal formula that if a behavior violates it – meaningthat if the formula is false on the behavior, then that violation occurs at someparticular point in the behavior.

And nothing in the behavior past that point can prevent the violation.

[ slide 154 ]

Page 155: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.Nothing past that point makes any difference.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

A safety formula is a temporal formula that asserts only what may happen.

More precisely, it’s a temporal formula that if a behavior violates it – meaningthat if the formula is false on the behavior, then that violation occurs at someparticular point in the behavior.

And nothing in the behavior past that point can prevent the violation.

[ slide 155 ]

Page 156: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

For example the kind of specification we’ve been writing can be violated by abehavior only if either The initial formula is false on the behavior’s first state,or the action Next sub vars is false on some step.

Remember that this action false on a step means that the step neithersatisfies the action Next nor leaves the tuple vars of variables unchanged.

[ slide 156 ]

Page 157: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

For example the kind of specification we’ve been writing can be violated by abehavior only if either The initial formula is false on the behavior’s first state,or the action Next sub vars is false on some step.

Remember that this action false on a step means that the step neithersatisfies the action Next nor leaves the tuple vars of variables unchanged.

[ slide 157 ]

Page 158: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

For example the kind of specification we’ve been writing can be violated by abehavior only if either The initial formula is false on the behavior’s first state,or the action Next sub vars is false on some step.

Remember that this action false on a step means that the step neithersatisfies the action Next nor leaves the tuple vars of variables unchanged.

[ slide 158 ]

Page 159: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .The step neither satisfies Next nor leaves vars unchanged.

Nothing past that point can make any difference.

For example the kind of specification we’ve been writing can be violated by abehavior only if either The initial formula is false on the behavior’s first state,or the action Next sub vars is false on some step.

Remember that this action false on a step means that the step neithersatisfies the action Next nor leaves the tuple vars of variables unchanged.

[ slide 159 ]

Page 160: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Safety Formula

Asserts what may happen.

Any behavior that violates it does so atsome point.

Example: Init ∧ 2 [Next ]vars can be violated either:

at an initial state not satisfying Init

or at a step not satisfying [Next ]vars .

Nothing past that point can make any difference.

And nothing in the behavior past that point of violation can cause the formulato be true.

[ slide 160 ]

Page 161: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

A liveness formula is a temporal formula that asserts only what must happen.

More precisely, it’s a temporal formula for which a behavior can not violate itat any particular point.

[ slide 161 ]

Page 162: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

A liveness formula is a temporal formula that asserts only what must happen.

More precisely, it’s a temporal formula for which a behavior can not violate itat any particular point.

[ slide 162 ]

Page 163: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

A liveness formula is a temporal formula that asserts only what must happen.

More precisely, it’s a temporal formula for which a behavior can not violate itat any particular point.

[ slide 163 ]

Page 164: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

The rest of the behavior can alwaysmake it true.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

At any point in a behavior, there’s a way to complete the behavior so itsatisfies the formula.

An example of a liveness formula is one asserting that x equals 5 on somestate of the behavior.

We’ll see in a minute how to write a formula that asserts this.

[ slide 164 ]

Page 165: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

At any point in a behavior, there’s a way to complete the behavior so itsatisfies the formula.

An example of a liveness formula is one asserting that x equals 5 on somestate of the behavior.

We’ll see in a minute how to write a formula that asserts this.

[ slide 165 ]

Page 166: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .We’ll see later how to write a formula that asserts this.

At any point, it’s always possible for a later stateto satisfy x = 5.

At any point in a behavior, there’s a way to complete the behavior so itsatisfies the formula.

An example of a liveness formula is one asserting that x equals 5 on somestate of the behavior.

We’ll see in a minute how to write a formula that asserts this.

[ slide 166 ]

Page 167: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

At any point in a behavior, it’s always possible for x to equal 5 in some laterstate.

So the behavior isn’t violated at that point.

Remember that a behavior is any infinite sequence of states. We’re nottalking only about behaviors that satisfy some specification.[ slide 167 ]

Page 168: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

At any point in a behavior, it’s always possible for x to equal 5 in some laterstate.

So the behavior isn’t violated at that point.

Remember that a behavior is any infinite sequence of states. We’re nottalking only about behaviors that satisfy some specification.[ slide 168 ]

Page 169: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness Formula

Asserts what must happen.

A behavior can not violate it at any point.

Example: x = 5 on some state of the behavior .

At any point, it’s always possible for a later stateto satisfy x = 5.

A behavior is any infinite sequence of states.

At any point in a behavior, it’s always possible for x to equal 5 in some laterstate.

So the behavior isn’t violated at that point.

Remember that a behavior is any infinite sequence of states. We’re nottalking only about behaviors that satisfy some specification.[ slide 169 ]

Page 170: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

x = 5 on some state of the behavior

asserted by 3 (x = 5)

“x equals 5 is true on some state of the behavior” is asserted by thistemporal formula.

where this symbol is typed less-than greater than and pronouncedeventually.

[ slide 170 ]

Page 171: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

x = 5 on some state of the behavior

asserted by 3 (x = 5)

“x equals 5 is true on some state of the behavior” is asserted by thistemporal formula.

where this symbol is typed less-than greater than and pronouncedeventually.

[ slide 171 ]

Page 172: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

x = 5 on some state of the behavior

asserted by 3 (x = 5)typed <>

“x equals 5 is true on some state of the behavior” is asserted by thistemporal formula.

where this symbol is typed less-than greater than and pronouncedeventually.

[ slide 172 ]

Page 173: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

x = 5 on some state of the behavior

asserted by 3 (x = 5)typed <>

pronounced eventually

“x equals 5 is true on some state of the behavior” is asserted by thistemporal formula.

where this symbol is typed less-than greater than and pronouncedeventually.

[ slide 173 ]

Page 174: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

x = 5 on some state of the behavior

asserted by 3 (x = 5)

“x equals 5 is true on some state of the behavior” is asserted by thistemporal formula.

where this symbol is typed less-than greater than and pronouncedeventually.

[ slide 174 ]

Page 175: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The only liveness property sequential programsmust satisfy is termination.

3 Terminated

Concurrent systems can have a widevariety of liveness requirements.

The only liveness property sequential programs must satisfy is termination.

It’s expressed by the formula eventually Terminated , for a state formulaTerminated which asserts that the program has reached a terminated state.

Concurrent systems can have a wide variety of liveness requirements.

[ slide 175 ]

Page 176: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The only liveness property sequential programsmust satisfy is termination.

3 Terminated

Concurrent systems can have a widevariety of liveness requirements.

The only liveness property sequential programs must satisfy is termination.

It’s expressed by the formula eventually Terminated , for a state formulaTerminated which asserts that the program has reached a terminated state.

Concurrent systems can have a wide variety of liveness requirements.

[ slide 176 ]

Page 177: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The only liveness property sequential programsmust satisfy is termination.

3 Terminated

Concurrent systems can have a widevariety of liveness requirements.

The only liveness property sequential programs must satisfy is termination.

It’s expressed by the formula eventually Terminated , for a state formulaTerminated which asserts that the program has reached a terminated state.

Concurrent systems can have a wide variety of liveness requirements.

[ slide 177 ]

Page 178: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.

(AVar = 〈“hi”,0〉) ; (BVar = 〈“hi”,0〉)

Here’s a liveness property we might like the AB protocol to ensure.

If AVar equals the pair “hi” zero in some statewhich means it’s a state in which A is sending that pair to B

then BVar equals this pair either in that state or in a later state.which means it’s a state in which B has received the pair.That property is expressed in TLA+

[ slide 178 ]

Page 179: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.

(AVar = 〈“hi”,0〉) ; (BVar = 〈“hi”,0〉)

Here’s a liveness property we might like the AB protocol to ensure.

If AVar equals the pair “hi” zero in some statewhich means it’s a state in which A is sending that pair to B

then BVar equals this pair either in that state or in a later state.which means it’s a state in which B has received the pair.That property is expressed in TLA+

[ slide 179 ]

Page 180: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some stateA is sending 〈“hi”, 0〉

then BVar = 〈“hi”, 0〉 in that state or a later state.

(AVar = 〈“hi”, 0〉) ; (BVar = 〈“hi”, 0〉)

Here’s a liveness property we might like the AB protocol to ensure.

If AVar equals the pair “hi” zero in some statewhich means it’s a state in which A is sending that pair to B

then BVar equals this pair either in that state or in a later state.which means it’s a state in which B has received the pair.That property is expressed in TLA+

[ slide 180 ]

Page 181: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.

(AVar = 〈“hi”,0〉) ; (BVar = 〈“hi”,0〉)

Here’s a liveness property we might like the AB protocol to ensure.

If AVar equals the pair “hi” zero in some statewhich means it’s a state in which A is sending that pair to B

then BVar equals this pair either in that state or in a later state.which means it’s a state in which B has received the pair.That property is expressed in TLA+

[ slide 181 ]

Page 182: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.B has received 〈“hi”, 0〉

(AVar = 〈“hi”, 0〉) ; (BVar = 〈“hi”, 0〉)

Here’s a liveness property we might like the AB protocol to ensure.

If AVar equals the pair “hi” zero in some statewhich means it’s a state in which A is sending that pair to B

then BVar equals this pair either in that state or in a later state.which means it’s a state in which B has received the pair.That property is expressed in TLA+

[ slide 182 ]

Page 183: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.

(AVar = 〈“hi”,0〉) ; (BVar = 〈“hi”,0〉)

by this temporal formula, where

this symbol is read leads to

and is typed in ascii as tilde greater-than.

[ slide 183 ]

Page 184: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.

(AVar = 〈“hi”,0〉) ; (BVar = 〈“hi”,0〉)pronounced leads to

by this temporal formula, where

this symbol is read leads to

and is typed in ascii as tilde greater-than.

[ slide 184 ]

Page 185: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Liveness property for ABSpec :

If AVar = 〈“hi”,0〉 in some statethen BVar = 〈“hi”,0〉 in that state or a later state.

(AVar = 〈“hi”,0〉) ; (BVar = 〈“hi”,0〉)typed ~>

by this temporal formula, where

this symbol is read leads to

and is typed in ascii as tilde greater-than.

[ slide 185 ]

Page 186: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

More generally:

Any value being sent by A is eventually received by B .

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

Exercise: Convince yourself that3P is equivalent to ¬2¬P .

In general, we’d like the AB protocol to satisfy this property:Any value being sent by A is eventually received by B .

This is expressed as follows:

For all v in this set, which is the set of all possible values of AVar andBVar .

[ slide 186 ]

Page 187: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

More generally:

Any value being sent by A is eventually received by B .

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

Exercise: Convince yourself that3P is equivalent to ¬2¬P .

In general, we’d like the AB protocol to satisfy this property:Any value being sent by A is eventually received by B .

This is expressed as follows:

For all v in this set, which is the set of all possible values of AVar andBVar .

[ slide 187 ]

Page 188: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

More generally:

Any value being sent by A is eventually received by B .

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

Exercise: Convince yourself that3P is equivalent to ¬2¬P .

In general, we’d like the AB protocol to satisfy this property:Any value being sent by A is eventually received by B .

This is expressed as follows:

For all v in this set, which is the set of all possible values of AVar andBVar .

[ slide 188 ]

Page 189: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

More generally:

Any value being sent by A is eventually received by B .

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

the possible values of AVar and BVar

Exercise: Convince yourself that3P is equivalent to ¬2¬P .

In general, we’d like the AB protocol to satisfy this property:Any value being sent by A is eventually received by B .

This is expressed as follows:

For all v in this set, which is the set of all possible values of AVar andBVar .

[ slide 189 ]

Page 190: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

More generally:

Any value being sent by A is eventually received by B .

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

Exercise: Convince yourself that3P is equivalent to ¬2¬P .

AVar equals v leads to BVar equals v .

As an exercise, convince yourself that eventually P is equivalent to notalways not P.[ slide 190 ]

Page 191: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

More generally:

Any value being sent by A is eventually received by B .

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

Exercise: Convince yourself that3P is equivalent to ¬2¬P .

AVar equals v leads to BVar equals v .

As an exercise, convince yourself that eventually P is equivalent to notalways not P.[ slide 191 ]

Page 192: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

WEAK FAIRNESS

[ slide 192 ]

Page 193: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that A is true on s → t .

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

Enabled.

[ slide 193 ]

Page 194: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that A is true on s → t .

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

Let A be an arbitrary action. A is said to be enabled in a state s if and only ifthere is some next state t such that A is true on the step from s to t .

Instead of saying A is true on the step s to t , we often say that s to t is an A

step.

As an example, remember action A of ABSpec which is defined like this.

[ slide 194 ]

Page 195: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that A is true on s → t .

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

Let A be an arbitrary action. A is said to be enabled in a state s if and only ifthere is some next state t such that A is true on the step from s to t .

Instead of saying A is true on the step s to t , we often say that s to t is an A

step.

As an example, remember action A of ABSpec which is defined like this.

[ slide 195 ]

Page 196: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

Let A be an arbitrary action. A is said to be enabled in a state s if and only ifthere is some next state t such that A is true on the step from s to t .

Instead of saying A is true on the step s to t , we often say that s to t is an A

step.

As an example, remember action A of ABSpec which is defined like this.

[ slide 196 ]

Page 197: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

Let A be an arbitrary action. A is said to be enabled in a state s if and only ifthere is some next state t such that A is true on the step from s to t .

Instead of saying A is true on the step s to t , we often say that s to t is an A

step.

As an example, remember action A of ABSpec which is defined like this.

[ slide 197 ]

Page 198: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

For it to be enabled The first conjunct must be true.A conjunct with no primes is an assertion about the first state, so it’s anenabling condition for an action.

We can obviously choose values of AVar and BVar in the next state to makethese two conjuncts true –except that the second conjunct is false if Data is the empty set, so Data

must be non-empty for A to be enabled.

[ slide 198 ]

Page 199: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

For it to be enabled The first conjunct must be true.A conjunct with no primes is an assertion about the first state, so it’s anenabling condition for an action.

We can obviously choose values of AVar and BVar in the next state to makethese two conjuncts true –except that the second conjunct is false if Data is the empty set, so Data

must be non-empty for A to be enabled.

[ slide 199 ]

Page 200: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

For it to be enabled The first conjunct must be true.A conjunct with no primes is an assertion about the first state, so it’s anenabling condition for an action.

We can obviously choose values of AVar and BVar in the next state to makethese two conjuncts true –except that the second conjunct is false if Data is the empty set, so Data

must be non-empty for A to be enabled.

[ slide 200 ]

Page 201: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

For it to be enabled The first conjunct must be true.A conjunct with no primes is an assertion about the first state, so it’s anenabling condition for an action.

We can obviously choose values of AVar and BVar in the next state to makethese two conjuncts true –except that the second conjunct is false if Data is the empty set, so Data

must be non-empty for A to be enabled.

[ slide 201 ]

Page 202: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Enabled

An action A is enabled in a state s iff there isa state t such that s → t is an A step.

For example, action A of ABSpec

A∆= ∧ AVar = BVar

∧ ∃ d ∈ Data : AVar ′ = 〈d ,1− AVar [2]〉∧ BVar ′ = BVar

is enabled iff AVar = BVar and Data 6= {} .

For it to be enabled The first conjunct must be true.A conjunct with no primes is an assertion about the first state, so it’s anenabling condition for an action.

We can obviously choose values of AVar and BVar in the next state to makethese two conjuncts true –except that the second conjunct is false if Data is the empty set, so Data

must be non-empty for A to be enabled.

[ slide 202 ]

Page 203: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42 → s43 → s44 → s45 → s46 → s47 → s48 → s49 → s50 → · · ·A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 203 ]

Page 204: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42 → s43 → s44 → s45 → s46 → s47 → s48 → s49 → s50 → · · ·A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 204 ]

Page 205: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42 → s43 → s44 → s45 → s46 → s47 → s48 → s49 → s50 → · · ·A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 205 ]

Page 206: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43 → s44 → s45 → s46 → s47 → s48 → s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 206 ]

Page 207: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44 → s45 → s46 → s47 → s48 → s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 207 ]

Page 208: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45 → s46 → s47 → s48 → s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 208 ]

Page 209: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46 → s47 → s48 → s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 209 ]

Page 210: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47 → s48 → s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 210 ]

Page 211: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47

true→ s48 → s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 211 ]

Page 212: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47

true→ s48

true→ s49 → s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 212 ]

Page 213: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47

true→ s48

true→ s49

true→ s50 → · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 213 ]

Page 214: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47

true→ s48

true→ s49

true→ s50

true→ · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Weak fairness of action A asserts of a behavior: that if A ever remainscontinuously enabled, then an A step must eventually occur.

For example, suppose we have a behavior, And A enabled is false in thisstate, then true, then false again, then true, and it remains continuouslytrue

[ slide 214 ]

Page 215: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47

true→ s48

true→ s49

true→ s50

true→ · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Then an A step must occur in this green part of the behavior.

After which, A need not remain enabled.

An equivalent way of saying this is that A cannot remain enabled foreverwithout another A step occurring.

[ slide 215 ]

Page 216: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of action A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

· · · → s42

false→ s43

true→ s44

false→ s45

true→ s46

true→ s47

true→ s48

true→ s49

true→ s50

true→ · · ·

A enabled:

Or equivalently:

A cannot remain enabled foreverwithout another A step occurring.

Then an A step must occur in this green part of the behavior.

After which, A need not remain enabled.

An equivalent way of saying this is that A cannot remain enabled foreverwithout another A step occurring.

[ slide 216 ]

Page 217: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of A is written as the temporalformula WFvars(A) , where vars is the tuple ofall the spec’s variables.

Later, we’ll see the strong fairness formula SFvars(A) .

Weak fairness of A is written as this temporal formula, where vars is thetuple of all the spec’s variables.

It’s typed as WF underscore vars parentheses A in ASCII.

It’s usually read “WF of A”, omitting the vars.

I’ll explain the vars later.

[ slide 217 ]

Page 218: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of A is written as the temporalformula WFvars(A) , where vars is the tuple ofall the spec’s variables.WF_vars(A) in ASCII

Later, we’ll see the strong fairness formula SFvars(A) .

Weak fairness of A is written as this temporal formula, where vars is thetuple of all the spec’s variables.

It’s typed as WF underscore vars parentheses A in ASCII.

It’s usually read “WF of A”, omitting the vars.

I’ll explain the vars later.

[ slide 218 ]

Page 219: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of A is written as the temporalformula WFvars(A) , where vars is the tuple ofall the spec’s variables.WF_vars(A) in ASCII

Pronounced “WF of A”

Later, we’ll see the strong fairness formula SFvars(A) .

Weak fairness of A is written as this temporal formula, where vars is thetuple of all the spec’s variables.

It’s typed as WF underscore vars parentheses A in ASCII.

It’s usually read “WF of A”, omitting the vars.

I’ll explain the vars later.

[ slide 219 ]

Page 220: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of A is written as the temporalformula WFvars(A) , where vars is the tuple ofall the spec’s variables.WF_vars(A) in ASCII

Pronounced “WF of A”

I’ll explain the vars later.

Later, we’ll see the strong fairness formula SFvars(A) .

Weak fairness of A is written as this temporal formula, where vars is thetuple of all the spec’s variables.

It’s typed as WF underscore vars parentheses A in ASCII.

It’s usually read “WF of A”, omitting the vars.

I’ll explain the vars later.

[ slide 220 ]

Page 221: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of A is written as the temporalformula WFvars(A) , where vars is the tuple ofall the spec’s variables.

It’s a liveness property because it can always be madetrue by an A step or a state in which A is not enabled.

Later, we’ll see the strong fairness formula SFvars(A) .

WF of A is a liveness property because, at any point in a behavior, it can bemade true by an A step or a state in which A is not enabled.

Later, in the second part of this lecture, we’ll see the strong fairness formulaSF of A.

[ slide 221 ]

Page 222: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Weak fairness of A is written as the temporalformula WFvars(A) , where vars is the tuple ofall the spec’s variables.

It’s a liveness property because it can always be madetrue by an A step or a state in which A is not enabled.

Later, we’ll see the strong fairness formula SFvars(A) .

WF of A is a liveness property because, at any point in a behavior, it can bemade true by an A step or a state in which A is not enabled.

Later, in the second part of this lecture, we’ll see the strong fairness formulaSF of A.

[ slide 222 ]

Page 223: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

ADDING LIVENESS TO A SPEC

[ slide 223 ]

Page 224: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled

A TLA+ spec with liveness is written in this formwhere Fairness is a conjunction of one or more WF and/or SF of A formulasand each A is a subaction of Next Which means that every possible A stepis a Next step.

[ slide 224 ]

Page 225: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

A conjunction of WFvars(A) and SFvars(A) formulaswhere each A is a subaction of Next .

Every A step is a Next step.

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled

A TLA+ spec with liveness is written in this formwhere Fairness is a conjunction of one or more WF and/or SF of A formulasand each A is a subaction of Next Which means that every possible A stepis a Next step.

[ slide 225 ]

Page 226: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

A conjunction of WFvars(A) and SFvars(A) formulaswhere each A is a subaction of Next .

Every A step is a Next step.

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled

A TLA+ spec with liveness is written in this formwhere Fairness is a conjunction of one or more WF and/or SF of A formulasand each A is a subaction of Next Which means that every possible A stepis a Next step.

[ slide 226 ]

Page 227: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

A conjunction of WFvars(A) and SFvars(A) formulaswhere each A is a subaction of Next .

Every A step is a Next step.

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled

A TLA+ spec with liveness is written in this formwhere Fairness is a conjunction of one or more WF and/or SF of A formulasand each A is a subaction of Next Which means that every possible A stepis a Next step.

[ slide 227 ]

Page 228: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled

Module ABSpec defines FairSpec to be this specification, Where WF of Nextasserts that a behavior keeps taking Next steps as long as Next is enabled.

Which means as long as the system is not in a deadlocked or terminatedstate.

[ slide 228 ]

Page 229: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled.

Module ABSpec defines FairSpec to be this specification, Where WF of Nextasserts that a behavior keeps taking Next steps as long as Next is enabled.

Which means as long as the system is not in a deadlocked or terminatedstate.

[ slide 229 ]

Page 230: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled.

not in a deadlocked / terminated state

Module ABSpec defines FairSpec to be this specification, Where WF of Nextasserts that a behavior keeps taking Next steps as long as Next is enabled.

Which means as long as the system is not in a deadlocked or terminatedstate.

[ slide 230 ]

Page 231: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled.

not in a deadlocked / terminated state

And the safety part of the spec implies that such a state cannot be reached.

So the behavior must keep taking Next steps, with A sending and B

receiving values forever.

[ slide 231 ]

Page 232: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

A spec with liveness is written

Init ∧2[Next ]vars ∧ Fairness

Module ABSpec defines

FairSpec∆= Init ∧2[Next ]vars ∧WFvars(Next)

Asserts that a behavior keeps taking Next stepsas long as Next is enabled – which means itkeeps sending and receiving values forever.

And the safety part of the spec implies that such a state cannot be reached.

So the behavior must keep taking Next steps, with A sending and B

receiving values forever.

[ slide 232 ]

Page 233: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Clone the model you’ve created for ABSpec

[ slide 233 ]

Page 234: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

For liveness checking, your model must not have anysymmetry set.

For liveness checking, your model must not have any symmetry set.

If it does, change it.

[ slide 234 ]

Page 235: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

For liveness checking, your model must not have anysymmetry set.

For liveness checking, your model must not have any symmetry set.

If it does, change it.

[ slide 235 ]

Page 236: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

For liveness checking, your model must not have anysymmetry set.

For liveness checking, your model must not have any symmetry set.

If it does, change it.

[ slide 236 ]

Page 237: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

For liveness checking, your model must not have anysymmetry set.

For liveness checking, your model must not have any symmetry set.

If it does, change it.

[ slide 237 ]

Page 238: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

For liveness checking, your model must not have anysymmetry set.

For liveness checking, your model must not have any symmetry set.

If it does, change it.

[ slide 238 ]

Page 239: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Set its behavior spec to FairSpec.

[ slide 239 ]

Page 240: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Have TLC check this temporal property:

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

You can copy it from the Web page.

Have TLC check that FairSpec satisfies this liveness property, which welooked at before.

You can copy it from the Web page.

[ slide 240 ]

Page 241: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Have TLC check this temporal property:

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

You can copy it from the Web page.

Have TLC check that FairSpec satisfies this liveness property, which welooked at before.

You can copy it from the Web page.

[ slide 241 ]

Page 242: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Have TLC check this temporal property:

∀ v ∈ Data × {0, 1} : (AVar = v) ; (BVar = v)

You can copy it from the Web page.

Have TLC check that FairSpec satisfies this liveness property, which welooked at before.

You can copy it from the Web page.

[ slide 242 ]

Page 243: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Another possible high-level spec of the AB protocol:Init ∧2[Next ]vars ∧WFvars(B)

Action B is enabled when the sender has sent a value that hasn’tbeen received.

It remains enabled until a B step occurs.

This spec requires every sent value to be received,but allows the sender to stop sending.

Here’s another possible high-level spec of the AB protocol.which has this fairness requirement.

Action B is enabled when the sender has sent a value that hasn’t beenreceived.And it remains enabled until a B step occurs.

[ slide 243 ]

Page 244: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Another possible high-level spec of the AB protocol:Init ∧2[Next ]vars ∧WFvars(B)

Action B is enabled when the sender has sent a value that hasn’tbeen received.

It remains enabled until a B step occurs.

This spec requires every sent value to be received,but allows the sender to stop sending.

Here’s another possible high-level spec of the AB protocol.which has this fairness requirement.

Action B is enabled when the sender has sent a value that hasn’t beenreceived.And it remains enabled until a B step occurs.

[ slide 244 ]

Page 245: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Another possible high-level spec of the AB protocol:Init ∧2[Next ]vars ∧WFvars(B)

Action B is enabled when the sender has sent a value that hasn’tbeen received.

It remains enabled until a B step occurs.

This spec requires every sent value to be received,but allows the sender to stop sending.

Here’s another possible high-level spec of the AB protocol.which has this fairness requirement.

Action B is enabled when the sender has sent a value that hasn’t beenreceived.And it remains enabled until a B step occurs.

[ slide 245 ]

Page 246: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Another possible high-level spec of the AB protocol:Init ∧2[Next ]vars ∧WFvars(B)

Action B is enabled when the sender has sent a value that hasn’tbeen received.

It remains enabled until a B step occurs.

This spec requires every sent value to be received,but allows the sender to stop sending.

Here’s another possible high-level spec of the AB protocol.which has this fairness requirement.

Action B is enabled when the sender has sent a value that hasn’t beenreceived.And it remains enabled until a B step occurs.

[ slide 246 ]

Page 247: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Another possible high-level spec of the AB protocol:Init ∧2[Next ]vars ∧WFvars(B)

Action B is enabled when the sender has sent a value that hasn’tbeen received.

It remains enabled until a B step occurs.

This spec requires every sent value to be received,but allows the sender to stop sending.

This spec requires every sent value to be received,but allows the sender to stop sending at any time.

[ slide 247 ]

Page 248: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

Exercise Explain why these two formulas are equivalent,when Init , Next , . . . are defined as in module ABSpec :

Init ∧ 2[Next ]vars ∧ WFvars(Next)

Init ∧ 2[Next ]vars ∧ WFvars(A) ∧ WFvars(B)

Use TLC to check their equivalence.

Here’s an exercise for you. Explain why these two formulas are equivalent,when Init , Next , and so on are defined as they are in module ABSpec.

And use TLC to check that they really are equivalent.

[ slide 248 ]

Page 249: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The vars Subscript

An A ∧ (vars ′ 6= vars) step is a non-stutteringA step.

It makes no sense to require a stuttering stepto occur.

Here’s what that vars subscript is all about.

Remember our definition of weak fairness of an action A.

WF of A means weak fairness of the action A and vars prime not equal tovars.

A step of that action is a non-stuttering A step.

[ slide 249 ]

Page 250: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The vars Subscript

Weak fairness of A asserts of a behavior:

If A ever remains continuously enabled,then an A step must eventually occur.

An A ∧ (vars ′ 6= vars) step is a non-stutteringA step.

It makes no sense to require a stuttering stepto occur.

Here’s what that vars subscript is all about.

Remember our definition of weak fairness of an action A.

WF of A means weak fairness of the action A and vars prime not equal tovars.

A step of that action is a non-stuttering A step.

[ slide 250 ]

Page 251: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The vars Subscript

WFvars(A) asserts of a behavior:

If A ∧ (vars ′ 6= vars) ever remains continuously enabled,then an A ∧ (vars ′ 6= vars) step must eventually occur.

An A ∧ (vars ′ 6= vars) step is a non-stutteringA step.

It makes no sense to require a stuttering stepto occur.

Here’s what that vars subscript is all about.

Remember our definition of weak fairness of an action A.

WF of A means weak fairness of the action A and vars prime not equal tovars.

A step of that action is a non-stuttering A step.

[ slide 251 ]

Page 252: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The vars Subscript

WFvars(A) asserts of a behavior:

If A ∧ (vars ′ 6= vars) ever remains continuously enabled,then an A ∧ (vars ′ 6= vars) step must eventually occur.

An A ∧ (vars ′ 6= vars) step is a non-stutteringA step.

It makes no sense to require a stuttering stepto occur.

Here’s what that vars subscript is all about.

Remember our definition of weak fairness of an action A.

WF of A means weak fairness of the action A and vars prime not equal tovars.

A step of that action is a non-stuttering A step.

[ slide 252 ]

Page 253: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

The vars Subscript

WFvars(A) asserts of a behavior:

If A ∧ (vars ′ 6= vars) ever remains continuously enabled,then an A ∧ (vars ′ 6= vars) step must eventually occur.

An A ∧ (vars ′ 6= vars) step is a non-stutteringA step.

It makes no sense to require a stuttering stepto occur.

We add the non-stuttering requirement because it makes no sense to requirea stuttering step to occur, since there’s no way of telling whether it did.

[ slide 253 ]

Page 254: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

You now know what the AB protocol is supposed to do, but you still don’tknow how it does it. And what is this mysterious strong fairness? Tune in tothe second exciting part of this lecture to find out.

Meanwhile, you’ll be happy to learn that sequences are the last of thecommonly used TLA+ data types that you need to know. And you’ve seenalmost all of the built-in TLA+ operators on those data types.

[ slide 254 ]

Page 255: THE ALTERNATING BIT PROTOCOL - Microsoft Azure · TLA+ Video Course – Lecture 9, Part 1 Leslie Lamport THE ALTERNATING BIT PROTOCOL THE HIGH LEVEL SPECIFICATION This video should

TLA+ Video Course

End of Lecture 9, Part 1

THE ALTERNATING BIT PROTOCOLTHE HIGH LEVEL SPECIFICATION

[ slide 255 ]