A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer...

118
A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA + Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 1 / 52

Transcript of A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer...

Page 1: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

A Tutorial Introduction to TLAPS

Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1

1

2

TLA+ Community Event, ABZ 2014Toulouse, June 3, 2014

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 1 / 52

Page 2: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Outline

1 TLAPS Basics

2 Tips and Best Practices for Using TLAPS

3 Temporal Reasoning in TLAPS

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 2 / 52

Page 3: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

TLAPS in Context

TLA: specification language

proof languagehierarchical structuring + tactics

TLAPS: proof managercompiles proofs into obligations

SMT solvers(Z3, CVC)

1st-order solvers(Zenon)

Isabelle Modal solvers(LS4)

. . . ?

TLAPS: proof system

TL

C:m

odel

chec

ker

PLUSCAL: pseudo code

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 3 / 52

Page 4: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

TLAPS in Context

TLA: specification language

proof languagehierarchical structuring + tactics

TLAPS: proof managercompiles proofs into obligations

SMT solvers(Z3, CVC)

1st-order solvers(Zenon)

Isabelle Modal solvers(LS4)

. . . ?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 4 / 52

Page 5: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

TLAPS in Context

TLAPS essentially does two things:

translate between TLA and the languages that the backendprovers understand;

help the user break up a theorem P into obligations O1 . . . On,while maintaining the fact that O1 ∧ . . . ∧On ⇒ P .

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 5 / 52

Page 6: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Talking to ATPs about TLA SpecsZ3, CVC

Zenon

Isabelle

LS4

SMTLIB2

certificates

“abcd”

“efgh”

“ijkl”

“mnop”

“prst”

“uvxy”

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 6 / 52

Page 7: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Talking to ATPs about TLA Specs

TLAPS

Z3, CVC

Zenon

Isabelle

LS4

OBVIOUSBY .. DEF ..ASSUME ... PROVE ...CASEPICKWITNESSSUFFICESUSEHIDEQED

Proof Language

ColoursSM

TLIB2cer

tificates

“abcd”

“efgh”

“ijkl”

“mnop”

“prst”

“uvxy”

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 7 / 52

Page 8: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Hence the way the interface looks:

conversation snipplets of conversationsuser⇐⇒ TLAPS TLAPS⇐⇒ backend provers

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 8 / 52

Page 9: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

TLAPS Proofs

There are two kinds of TLAPS proofs:

one-liners

OBVIOUS

BY . . . [DEF . . .]

Each one-line proof generatesone obligation.

(Or there abouts... )

hierarchical

〈1〉1 X〈2〉1 Y

OBVIOUS...〈2〉q QED

BY . . . DEF . . ....

〈1〉q QEDBY . . . DEF . . .

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 9 / 52

Page 10: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Obligations

An obligation is a claim of the form Γ ` P,which is translated and handed on to the backend provers.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 10 / 52

Page 11: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Obligations

An obligation is a claim of the form ASSUME Γ PROVE P,which is translated and handed on to the backend provers.

To prove an obligation, by default, TLAPS will ask:1 CVC2 Zenon3 Isabelle

But one can change that...

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 11 / 52

Page 12: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Obligations: Controlling Γ

An obligation is a claim of the form ASSUME Γ PROVE P,which is translated and handed on to the backend provers.

The TLAPS game is mainly to construct obligations so that:1 they are true, i.e.:

1 Γ contains all relevant facts), and2 all relevant definitions are unfolded;

2 they are not too big for the backend provers to handle.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 12 / 52

Page 13: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Obligations: Controlling Γ

Once one has one’s logic right, the game is to control Γ.

By default:all constant-/variable-declarations, with domain-assumptions, arein Γ;no definitions are unfolded.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 13 / 52

Page 14: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Obligations: Controlling Γ

Once one has one’s logic right, the game is to control Γ.

named & un-named steps

〈1〉1 X. . .

〈1〉 Y. . .

〈1〉3 Z(* here Y is in Γ, but X is not *)BY 〈1〉1 (* here Y and X are in Γ *)

USE & HIDE

The keywords USE resp. HIDE

include in resp. remove from Γsteps, theorems or assumptions;

USE [DEF] resp. HIDE [DEF] foldresp. unfold definitions in Γ.

Whether a USE- and HIDE-step is namedor un-named does not matter.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 14 / 52

Page 15: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Writing a simple Hierarchical Proof

quick recap: EWD 840

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 15 / 52

Page 16: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Writing a simple Hierarchical Proof

The safety-proof has the following structure:

LEMMA Spec⇒ 2TerminationDetection

(* Dijkstra’s invariant implies correctness *)〈1〉1 Inv⇒ TerminationDetection

(* Dijkstra’s invariant is (trivially) established by the initial condition *)〈1〉2 Init⇒ Inv

(* Dijkstra’s invariant is inductive relative to the type invariant *)〈1〉3 TypeOK ∧ Inv∧ [Next]vars ⇒ Inv′

〈1〉q QEDBY 〈1〉1, 〈1〉2, 〈1〉3, TypeOKinv, PTL DEF Spec

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 16 / 52

Page 17: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Writing a simple Hierarchical Proof

writing a simple hierarchical proof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 17 / 52

Page 18: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Some more Proof Constructs: WITNESS

When proving a goal of the form:

∃x ∈ S : P(x)

To prove it we can write:

〈1〉6 WITNESS a ∈ Sfor some a already in Γ.

The effect is:1 step 〈1〉6 needs a proof that a ∈ S;2 the goal from now on is P(a).

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 18 / 52

Page 19: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Some more Proof Constructs: PICK

When Γ contains a statement of the form:

∃x ∈ S : P(x)

To use it we can write:

〈1〉6 PICK a ∈ S : P(a)for some fresh a.

The effect is:1 we have a new a ∈ S in Γ;2 using 〈1〉6 will put P(a) into Γ.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 19 / 52

Page 20: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Some more Proof Constructs: SUFFICES

SUFFICES is useful to avoid deeply nested hierarchical proofs:

〈6〉4 X〈7〉 proof Π

〈6〉q QEDBY 〈6〉4, proof Σ

〈6〉4 SUFFICES Xproof Σ

〈6〉5 proof Π

〈6〉q QEDBY 〈6〉4, 〈6〉5

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 20 / 52

Page 21: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Outline

1 TLAPS Basics

2 Tips and Best Practices for Using TLAPS

3 Temporal Reasoning in TLAPS

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 21 / 52

Page 22: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

A simple theorem about sequences

Concat left cancellation: Given three sequences A, B, C whereC ◦A = C ◦ B, it follows that A = B.

I Simple, but not trivial. Multiplication, for example, does not haveleft cancellation, because you can multiply by zero.

Write the theorem in TLA

As a quantified formula:

∀ S : ∀A, B, C ∈ Seq(S) :C ◦A = C ◦ B⇒ A = B

As an ASSUME-PROVE:

ASSUME

NEW S,NEW A ∈ Seq(S),NEW B ∈ Seq(S),NEW C ∈ Seq(S),C ◦A = C ◦ B

PROVE A = B

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 22 / 52

Page 23: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

A simple theorem about sequences

Concat left cancellation: Given three sequences A, B, C whereC ◦A = C ◦ B, it follows that A = B.

I Simple, but not trivial. Multiplication, for example, does not haveleft cancellation, because you can multiply by zero.

Write the theorem in TLA

As a quantified formula:

∀ S : ∀A, B, C ∈ Seq(S) :C ◦A = C ◦ B⇒ A = B

As an ASSUME-PROVE:

ASSUME

NEW S,NEW A ∈ Seq(S),NEW B ∈ Seq(S),NEW C ∈ Seq(S),C ◦A = C ◦ B

PROVE A = B

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 22 / 52

Page 24: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

A simple theorem about sequences

Concat left cancellation: Given three sequences A, B, C whereC ◦A = C ◦ B, it follows that A = B.

I Simple, but not trivial. Multiplication, for example, does not haveleft cancellation, because you can multiply by zero.

Write the theorem in TLA

As a quantified formula:

∀ S : ∀A, B, C ∈ Seq(S) :C ◦A = C ◦ B⇒ A = B

As an ASSUME-PROVE:

ASSUME

NEW S,NEW A ∈ Seq(S),NEW B ∈ Seq(S),NEW C ∈ Seq(S),C ◦A = C ◦ B

PROVE A = B

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 22 / 52

Page 25: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

A simple theorem about sequences

Concat left cancellation: Given three sequences A, B, C whereC ◦A = C ◦ B, it follows that A = B.

I Simple, but not trivial. Multiplication, for example, does not haveleft cancellation, because you can multiply by zero.

Write the theorem in TLA

As a quantified formula:

∀ S : ∀A, B, C ∈ Seq(S) :C ◦A = C ◦ B⇒ A = B

As an ASSUME-PROVE:

ASSUME

NEW S,NEW A ∈ Seq(S),NEW B ∈ Seq(S),NEW C ∈ Seq(S),C ◦A = C ◦ B

PROVE A = B

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 22 / 52

Page 26: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Proof attempt 1 - is it obvious - fail

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉 QED OBVIOUS unable to prove it

Figure 1: First proof attempt (unsuccessful).

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ∀ i ∈ 1 . . Len(A) : A[i ] = (C ◦A)[i + Len(C )] OBVIOUS〈1〉5. ∀ i ∈ 1 . . Len(A) : B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉4, 〈1〉5 unable to prove it

Figure 2: Second proof attempt (also unsuccessful).

system considers obvious.1

Unfortunately, the TLA+ proof system is unable toprove our theorem immediately. Perhaps the proof sys-tem needs some additional facts. There are five facts thatseem relevant:

1. Because C ◦A = C ◦B , the lengths of A and B mustbe the same.

2. Because A ∈ Seq(S ), A is a function from 1 . .Len(A) to S .

3. Because B ∈ Seq(S ), B is a function from 1 . .Len(B ) to S .

4. From the definition of ◦ , each element of A mustappear in C ◦A at offset Len(C ).

5. From the definition of ◦ , each element of B mustappear in C ◦ B at offset Len(C ).

By using fact 1, we can write Len(A) instead of Len(B )in facts 3 and 5. Figure 2 shows our second attempt at aproof.

1And if you can ever catch it proving something that it could notpossibly prove, you might have the beginnings of a glorious bug report.

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ∀ i ∈ 1 . . Len(A) : A[i ] = (C ◦A)[i + Len(C )] OBVIOUS〈1〉5. ∀ i ∈ 1 . . Len(A) : B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1〈1〉6. ∀ i ∈ 1 . . Len(A) : A[i ] = B [i ] BY 〈1〉4, 〈1〉5〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉6

Figure 3: Third proof attempt (successful).

TLA+ proof system can prove each of our new factsimmediately. Unfortunately, even using these new facts,the TLA+ proof system still cannot prove our theorem.

We have to guess why the TLA+ proof system is unableto conclude the theorem from the facts at hand. Maybethe problem is that the proof system does not realize thatA[i ] = B [i ] for each i ∈ 1 . . Len(A).

So we write this fact down specifically as fact 6 andstate that it follows from facts 4 and 5. We justify themajor claim by fact 6 in place of facts 4 and 5. Figure 3shows our third attempt at a proof.

The TLA+ proof system can indeed verify that fact 6follows from facts 4 and 5. And using fact 6 it can provethe major claim.

Now that we have a proof of our theorem that the TLA+

proof system can verify, we can make it easier for humansto understand if we structure it more logically. In this case,facts 4 and 5 are used only to support fact 6, and we canmake this dependence clear by demoting them to a sub-proof of fact 6. Using this structure we can also simplifythese facts by extracting the identical quantifiers into anASSUME-PROVE. Figure 4 shows the result.

Of course, in more complicated proofs, it often turnsout that a certain fact is used in support of several otherfacts, in which case the only reasonable approach is toleave the supporting fact at the higher level so that it canbe referenced each time it is needed.

Lessons from this example:r The proof of ConcatLeftCancel centers on showingthat two functions, A and B , are equal. In order to provethat two functions are equal, you must show that they areboth functions with the same domain and that they havethe same value at each point in their domain. It wouldseem that the TLA+ proof system finds this a particularly

2

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 23 / 52

Page 27: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Proof attempt 2 - add some facts - still fail

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉 QED OBVIOUS unable to prove it

Figure 1: First proof attempt (unsuccessful).

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ∀ i ∈ 1 . . Len(A) : A[i ] = (C ◦A)[i + Len(C )] OBVIOUS〈1〉5. ∀ i ∈ 1 . . Len(A) : B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉4, 〈1〉5 unable to prove it

Figure 2: Second proof attempt (also unsuccessful).

system considers obvious.1

Unfortunately, the TLA+ proof system is unable toprove our theorem immediately. Perhaps the proof sys-tem needs some additional facts. There are five facts thatseem relevant:

1. Because C ◦A = C ◦B , the lengths of A and B mustbe the same.

2. Because A ∈ Seq(S ), A is a function from 1 . .Len(A) to S .

3. Because B ∈ Seq(S ), B is a function from 1 . .Len(B ) to S .

4. From the definition of ◦ , each element of A mustappear in C ◦A at offset Len(C ).

5. From the definition of ◦ , each element of B mustappear in C ◦ B at offset Len(C ).

By using fact 1, we can write Len(A) instead of Len(B )in facts 3 and 5. Figure 2 shows our second attempt at aproof.

1And if you can ever catch it proving something that it could notpossibly prove, you might have the beginnings of a glorious bug report.

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ∀ i ∈ 1 . . Len(A) : A[i ] = (C ◦A)[i + Len(C )] OBVIOUS〈1〉5. ∀ i ∈ 1 . . Len(A) : B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1〈1〉6. ∀ i ∈ 1 . . Len(A) : A[i ] = B [i ] BY 〈1〉4, 〈1〉5〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉6

Figure 3: Third proof attempt (successful).

TLA+ proof system can prove each of our new factsimmediately. Unfortunately, even using these new facts,the TLA+ proof system still cannot prove our theorem.

We have to guess why the TLA+ proof system is unableto conclude the theorem from the facts at hand. Maybethe problem is that the proof system does not realize thatA[i ] = B [i ] for each i ∈ 1 . . Len(A).

So we write this fact down specifically as fact 6 andstate that it follows from facts 4 and 5. We justify themajor claim by fact 6 in place of facts 4 and 5. Figure 3shows our third attempt at a proof.

The TLA+ proof system can indeed verify that fact 6follows from facts 4 and 5. And using fact 6 it can provethe major claim.

Now that we have a proof of our theorem that the TLA+

proof system can verify, we can make it easier for humansto understand if we structure it more logically. In this case,facts 4 and 5 are used only to support fact 6, and we canmake this dependence clear by demoting them to a sub-proof of fact 6. Using this structure we can also simplifythese facts by extracting the identical quantifiers into anASSUME-PROVE. Figure 4 shows the result.

Of course, in more complicated proofs, it often turnsout that a certain fact is used in support of several otherfacts, in which case the only reasonable approach is toleave the supporting fact at the higher level so that it canbe referenced each time it is needed.

Lessons from this example:r The proof of ConcatLeftCancel centers on showingthat two functions, A and B , are equal. In order to provethat two functions are equal, you must show that they areboth functions with the same domain and that they havethe same value at each point in their domain. It wouldseem that the TLA+ proof system finds this a particularly

2

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 24 / 52

Page 28: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Proof attempt 3 - another fact - success

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉 QED OBVIOUS unable to prove it

Figure 1: First proof attempt (unsuccessful).

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ∀ i ∈ 1 . . Len(A) : A[i ] = (C ◦A)[i + Len(C )] OBVIOUS〈1〉5. ∀ i ∈ 1 . . Len(A) : B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉4, 〈1〉5 unable to prove it

Figure 2: Second proof attempt (also unsuccessful).

system considers obvious.1

Unfortunately, the TLA+ proof system is unable toprove our theorem immediately. Perhaps the proof sys-tem needs some additional facts. There are five facts thatseem relevant:

1. Because C ◦A = C ◦B , the lengths of A and B mustbe the same.

2. Because A ∈ Seq(S ), A is a function from 1 . .Len(A) to S .

3. Because B ∈ Seq(S ), B is a function from 1 . .Len(B ) to S .

4. From the definition of ◦ , each element of A mustappear in C ◦A at offset Len(C ).

5. From the definition of ◦ , each element of B mustappear in C ◦ B at offset Len(C ).

By using fact 1, we can write Len(A) instead of Len(B )in facts 3 and 5. Figure 2 shows our second attempt at aproof.

1And if you can ever catch it proving something that it could notpossibly prove, you might have the beginnings of a glorious bug report.

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ∀ i ∈ 1 . . Len(A) : A[i ] = (C ◦A)[i + Len(C )] OBVIOUS〈1〉5. ∀ i ∈ 1 . . Len(A) : B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1〈1〉6. ∀ i ∈ 1 . . Len(A) : A[i ] = B [i ] BY 〈1〉4, 〈1〉5〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉6

Figure 3: Third proof attempt (successful).

TLA+ proof system can prove each of our new factsimmediately. Unfortunately, even using these new facts,the TLA+ proof system still cannot prove our theorem.

We have to guess why the TLA+ proof system is unableto conclude the theorem from the facts at hand. Maybethe problem is that the proof system does not realize thatA[i ] = B [i ] for each i ∈ 1 . . Len(A).

So we write this fact down specifically as fact 6 andstate that it follows from facts 4 and 5. We justify themajor claim by fact 6 in place of facts 4 and 5. Figure 3shows our third attempt at a proof.

The TLA+ proof system can indeed verify that fact 6follows from facts 4 and 5. And using fact 6 it can provethe major claim.

Now that we have a proof of our theorem that the TLA+

proof system can verify, we can make it easier for humansto understand if we structure it more logically. In this case,facts 4 and 5 are used only to support fact 6, and we canmake this dependence clear by demoting them to a sub-proof of fact 6. Using this structure we can also simplifythese facts by extracting the identical quantifiers into anASSUME-PROVE. Figure 4 shows the result.

Of course, in more complicated proofs, it often turnsout that a certain fact is used in support of several otherfacts, in which case the only reasonable approach is toleave the supporting fact at the higher level so that it canbe referenced each time it is needed.

Lessons from this example:r The proof of ConcatLeftCancel centers on showingthat two functions, A and B , are equal. In order to provethat two functions are equal, you must show that they areboth functions with the same domain and that they havethe same value at each point in their domain. It wouldseem that the TLA+ proof system finds this a particularly

2

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 25 / 52

Page 29: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Proof with better structure

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ASSUME NEW i ∈ 1 . . Len(A) PROVE A[i ] = B [i ]〈2〉1. A[i ] = (C ◦A)[i + Len(C )] OBVIOUS defn of C ◦A〈2〉2. B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1 defn of C ◦B〈2〉 QED BY 〈2〉1, 〈2〉2〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉4

Figure 4: Better structured proof.

hard conclusion to reach, and that the evidence must bepresented in a relatively explicit manner.r When developing a proof, check whether the proof sys-tem can verify a fact before going on to write a more de-tailed proof.r When the proof system fails to verify a fact (assumingit really is a fact), you have to scratch your head and figureout what more specific, supporting facts you can providethat perhaps the proof system is failing to consider. Inthis example, we went through this process twice beforearriving at a proof that the proof system could verify.r It is good practice, when introducing a new symbol xin a theorem, an ASSUME-PROVE, or a quantifier, tointroduce it with a domain formula, x ∈ S for some setS . The domain formula will become common knowledgethroughout the scope of the symbol and usually the proofsystem can use this knowledge advantageously.

2 Applying ConcatLeftCancel

Now let us consider an example in which we apply theConcatLeftCancel theorem that we proved in the previ-ous section.

Often, what a theorem considers as constant parame-ters are actually messy formulas at the point where wewish to apply the theorem. In other words, the situationcomplicated. For our example, we conjure up formulasthat happen to be sequences, present an instance of conca-tentation with common left-hand arguments, and ask theTLA+ proof system to apply our theorem from the previ-ous section. Figure 5 shows our example.

Unfortunately, the TLA+ proof system is unable to ap-ply the theorem. It was unable to recognize that the situ-

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉 QED BY ConcatLeftCancel unable to prove it

Figure 5: First use attempt (unsuccessful).

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉 QED BY 〈1〉1, ConcatLeftCancel unable to prove it

Figure 6: Second use attempt (also unsuccessful).

ation was, in fact, suitable for application of the theorem.One approach in such a case is to adduce more facts.

For our second attempt, we adduce an additional fact.Maybe the TLA+ proof system was unaware the u◦〈m , n〉is a sequence. We claim this fact and then attempt to use itto apply the theorem. Figure 6 shows the result. Althoughthe TLA+ proof system is able to prove our new fact im-mediately, it does not help in applying our theorem.

For our third attempt, we adduce some more facts.Maybe the TLA+ proof system was unaware that v ◦ xand w ◦ x are sequences. So we claim these facts and addthem to the justification of the application of the theorem.Figure 7 shows the result. Although the TLA+ proof sys-tem is able to prove these new facts immediately, usingthem still does not help in applying our theorem.

For our fourth attempt, we adduce yet another fact.Since ◦ is associative, we can reassociate the knownequality to make it explicit that v ◦x and w ◦x are presentin the formula. Figure 8 shows the result. The TLA+ proofsystem is able to prove the reassociated equality immedi-ately. Using all of the adduced facts, the proof system isfinally able to discover that the situation is an instance of

3

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 26 / 52

Page 30: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving ConcatLeftCancel

The proof centers on showing A = B where A, B are functionsI For two functions to be equal, you must show

F they have the same domainF they have the same value at each point in the domain

I It seems this is relatively difficult for TLAPS to conclude

Before writing a subproof, check if TLAPS thinks a fact is obviousWhen TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to considerWhen introducing a new symbol x, generally it is a good idea touse a domain formula x ∈ S

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 27 / 52

Page 31: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving ConcatLeftCancel

The proof centers on showing A = B where A, B are functionsI For two functions to be equal, you must show

F they have the same domainF they have the same value at each point in the domain

I It seems this is relatively difficult for TLAPS to conclude

Before writing a subproof, check if TLAPS thinks a fact is obviousWhen TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to considerWhen introducing a new symbol x, generally it is a good idea touse a domain formula x ∈ S

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 27 / 52

Page 32: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving ConcatLeftCancel

The proof centers on showing A = B where A, B are functionsI For two functions to be equal, you must show

F they have the same domainF they have the same value at each point in the domain

I It seems this is relatively difficult for TLAPS to conclude

Before writing a subproof, check if TLAPS thinks a fact is obvious

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to considerWhen introducing a new symbol x, generally it is a good idea touse a domain formula x ∈ S

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 27 / 52

Page 33: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving ConcatLeftCancel

The proof centers on showing A = B where A, B are functionsI For two functions to be equal, you must show

F they have the same domainF they have the same value at each point in the domain

I It seems this is relatively difficult for TLAPS to conclude

Before writing a subproof, check if TLAPS thinks a fact is obviousWhen TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

When introducing a new symbol x, generally it is a good idea touse a domain formula x ∈ S

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 27 / 52

Page 34: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving ConcatLeftCancel

The proof centers on showing A = B where A, B are functionsI For two functions to be equal, you must show

F they have the same domainF they have the same value at each point in the domain

I It seems this is relatively difficult for TLAPS to conclude

Before writing a subproof, check if TLAPS thinks a fact is obviousWhen TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to considerWhen introducing a new symbol x, generally it is a good idea touse a domain formula x ∈ S

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 27 / 52

Page 35: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Using the theorem ConcatLeftCancel

Often, what a theorem considers as constant parameters are messyformulas at the point where we wish to apply the theorem. In thisexample, we conjure up formulas that happen to be sequences, andask TLAPS to apply ConcatLeftCancel.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 28 / 52

Page 36: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Use attempt 1 - is it obvious - fail

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ASSUME NEW i ∈ 1 . . Len(A) PROVE A[i ] = B [i ]〈2〉1. A[i ] = (C ◦A)[i + Len(C )] OBVIOUS defn of C ◦A〈2〉2. B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1 defn of C ◦B〈2〉 QED BY 〈2〉1, 〈2〉2〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉4

Figure 4: Better structured proof.

hard conclusion to reach, and that the evidence must bepresented in a relatively explicit manner.r When developing a proof, check whether the proof sys-tem can verify a fact before going on to write a more de-tailed proof.r When the proof system fails to verify a fact (assumingit really is a fact), you have to scratch your head and figureout what more specific, supporting facts you can providethat perhaps the proof system is failing to consider. Inthis example, we went through this process twice beforearriving at a proof that the proof system could verify.r It is good practice, when introducing a new symbol xin a theorem, an ASSUME-PROVE, or a quantifier, tointroduce it with a domain formula, x ∈ S for some setS . The domain formula will become common knowledgethroughout the scope of the symbol and usually the proofsystem can use this knowledge advantageously.

2 Applying ConcatLeftCancel

Now let us consider an example in which we apply theConcatLeftCancel theorem that we proved in the previ-ous section.

Often, what a theorem considers as constant parame-ters are actually messy formulas at the point where wewish to apply the theorem. In other words, the situationcomplicated. For our example, we conjure up formulasthat happen to be sequences, present an instance of conca-tentation with common left-hand arguments, and ask theTLA+ proof system to apply our theorem from the previ-ous section. Figure 5 shows our example.

Unfortunately, the TLA+ proof system is unable to ap-ply the theorem. It was unable to recognize that the situ-

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉 QED BY ConcatLeftCancel unable to prove it

Figure 5: First use attempt (unsuccessful).

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉 QED BY 〈1〉1, ConcatLeftCancel unable to prove it

Figure 6: Second use attempt (also unsuccessful).

ation was, in fact, suitable for application of the theorem.One approach in such a case is to adduce more facts.

For our second attempt, we adduce an additional fact.Maybe the TLA+ proof system was unaware the u◦〈m , n〉is a sequence. We claim this fact and then attempt to use itto apply the theorem. Figure 6 shows the result. Althoughthe TLA+ proof system is able to prove our new fact im-mediately, it does not help in applying our theorem.

For our third attempt, we adduce some more facts.Maybe the TLA+ proof system was unaware that v ◦ xand w ◦ x are sequences. So we claim these facts and addthem to the justification of the application of the theorem.Figure 7 shows the result. Although the TLA+ proof sys-tem is able to prove these new facts immediately, usingthem still does not help in applying our theorem.

For our fourth attempt, we adduce yet another fact.Since ◦ is associative, we can reassociate the knownequality to make it explicit that v ◦x and w ◦x are presentin the formula. Figure 8 shows the result. The TLA+ proofsystem is able to prove the reassociated equality immedi-ately. Using all of the adduced facts, the proof system isfinally able to discover that the situation is an instance of

3

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 29 / 52

Page 37: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Use attempt 2 - add a closure fact - still fail

THEOREM ConcatLeftCancel∆

=

ASSUMENEW S ,NEW A ∈ Seq(S ),NEW B ∈ Seq(S ),NEW C ∈ Seq(S ),C ◦A = C ◦ B

PROVEA = B

PROOF〈1〉1. Len(A) = Len(B ) OBVIOUS C ◦A = C ◦B〈1〉2. A ∈ [1 . . Len(A)→ S ] OBVIOUS A ∈ Seq(S )〈1〉3. B ∈ [1 . . Len(A)→ S ] BY 〈1〉1〈1〉4. ASSUME NEW i ∈ 1 . . Len(A) PROVE A[i ] = B [i ]〈2〉1. A[i ] = (C ◦A)[i + Len(C )] OBVIOUS defn of C ◦A〈2〉2. B [i ] = (C ◦ B )[i + Len(C )] BY 〈1〉1 defn of C ◦B〈2〉 QED BY 〈2〉1, 〈2〉2〈1〉 QED BY 〈1〉2, 〈1〉3, 〈1〉4

Figure 4: Better structured proof.

hard conclusion to reach, and that the evidence must bepresented in a relatively explicit manner.r When developing a proof, check whether the proof sys-tem can verify a fact before going on to write a more de-tailed proof.r When the proof system fails to verify a fact (assumingit really is a fact), you have to scratch your head and figureout what more specific, supporting facts you can providethat perhaps the proof system is failing to consider. Inthis example, we went through this process twice beforearriving at a proof that the proof system could verify.r It is good practice, when introducing a new symbol xin a theorem, an ASSUME-PROVE, or a quantifier, tointroduce it with a domain formula, x ∈ S for some setS . The domain formula will become common knowledgethroughout the scope of the symbol and usually the proofsystem can use this knowledge advantageously.

2 Applying ConcatLeftCancel

Now let us consider an example in which we apply theConcatLeftCancel theorem that we proved in the previ-ous section.

Often, what a theorem considers as constant parame-ters are actually messy formulas at the point where wewish to apply the theorem. In other words, the situationcomplicated. For our example, we conjure up formulasthat happen to be sequences, present an instance of conca-tentation with common left-hand arguments, and ask theTLA+ proof system to apply our theorem from the previ-ous section. Figure 5 shows our example.

Unfortunately, the TLA+ proof system is unable to ap-ply the theorem. It was unable to recognize that the situ-

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉 QED BY ConcatLeftCancel unable to prove it

Figure 5: First use attempt (unsuccessful).

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉 QED BY 〈1〉1, ConcatLeftCancel unable to prove it

Figure 6: Second use attempt (also unsuccessful).

ation was, in fact, suitable for application of the theorem.One approach in such a case is to adduce more facts.

For our second attempt, we adduce an additional fact.Maybe the TLA+ proof system was unaware the u◦〈m , n〉is a sequence. We claim this fact and then attempt to use itto apply the theorem. Figure 6 shows the result. Althoughthe TLA+ proof system is able to prove our new fact im-mediately, it does not help in applying our theorem.

For our third attempt, we adduce some more facts.Maybe the TLA+ proof system was unaware that v ◦ xand w ◦ x are sequences. So we claim these facts and addthem to the justification of the application of the theorem.Figure 7 shows the result. Although the TLA+ proof sys-tem is able to prove these new facts immediately, usingthem still does not help in applying our theorem.

For our fourth attempt, we adduce yet another fact.Since ◦ is associative, we can reassociate the knownequality to make it explicit that v ◦x and w ◦x are presentin the formula. Figure 8 shows the result. The TLA+ proofsystem is able to prove the reassociated equality immedi-ately. Using all of the adduced facts, the proof system isfinally able to discover that the situation is an instance of

3

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 30 / 52

Page 38: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Use attempt 3 - add more closure facts - still fail

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉2. v ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉3. w ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉 QED BY 〈1〉1, 〈1〉2, 〈1〉3, ConcatLeftCancel unable to prove it

Figure 7: Third use attempt (still unsuccessful).

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉2. v ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉3. w ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉4. u ◦ 〈m , n〉 ◦ (v ◦ x ) = u ◦ 〈m , n〉 ◦ (w ◦ x ) OBVIOUS〈1〉 QED BY 〈1〉1, 〈1〉2, 〈1〉3, 〈1〉4, ConcatLeftCancel

Figure 8: Fourth use attempt (successful).

our theorem, and apply it.Lessons from this example:

r The application of ConcatLeftCancel shows how im-portant are the common mathematical properties of clo-sure and associativity. Humans are good at utilizing theseproperties when proving deductions. Even though theTLA+ proof system considered applications of closureand associativity as obvious, it was unable to supply themautomatically when trying to prove a deduction that re-quired them.r When the proof system fails to verify a fact, one ap-proach is to figure out what more specific, supporting factsyou can provide that perhaps the proof system is failing toconsider. In this example, we went through this processthree times before arriving at a proof that the proof sys-tem could verify.

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInduction

Figure 9: Setting up an inductive argument to proveFiniteNatInduction .

3 Finite induction over naturalsIn this section we define and prove a theorem about finiteinduction over the natural numbers. We use this theoremlater in Section 5.

The ordinary form of induction is simple induction overthe naturals, in which a predicate P (i ) is proved to holdfor all i ∈ Nat . The TLA+ proof system has a theoremNatInduction , in the library module NaturalsInduction ,which encapsulates the simple inductive argument. Forany predicate P ( ), given the base case

P (0)and the inductive step

∀ i ∈ Nat : P (i )⇒ P (i + 1)NatInduction concludes

∀ i ∈ Nat : P (i )

Sometimes, however, we do not want or need to provethat predicate P (i ) holds for all i ∈ Nat , but rather onlyfor a finite range i ∈ m . . n . Such a situation often occurswhen proving things about sequences, for example.

We could, of course, always employ NatInduction insuch cases, by defining a more general predicate that holdsfor all i ∈ Nat . However, the proof of the inductive stepwould be cluttered up dealing with the transition of i as itcrosses into and out of the range m . . n .

A better approach is to define and prove a theoremFiniteNatInduction that explicitly deals with finite in-duction over the naturals. This approach moves the tran-sitional clutter into the proof of FiniteNatInduction andmakes all the proofs that need to use finite induction a bitcleaner. Figure 9 shows our theorem and the first steps inits proof.

4

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 31 / 52

Page 39: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Use attempt 4 - add an associativity fact - success

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉2. v ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉3. w ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉 QED BY 〈1〉1, 〈1〉2, 〈1〉3, ConcatLeftCancel unable to prove it

Figure 7: Third use attempt (still unsuccessful).

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉2. v ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉3. w ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉4. u ◦ 〈m , n〉 ◦ (v ◦ x ) = u ◦ 〈m , n〉 ◦ (w ◦ x ) OBVIOUS〈1〉 QED BY 〈1〉1, 〈1〉2, 〈1〉3, 〈1〉4, ConcatLeftCancel

Figure 8: Fourth use attempt (successful).

our theorem, and apply it.Lessons from this example:

r The application of ConcatLeftCancel shows how im-portant are the common mathematical properties of clo-sure and associativity. Humans are good at utilizing theseproperties when proving deductions. Even though theTLA+ proof system considered applications of closureand associativity as obvious, it was unable to supply themautomatically when trying to prove a deduction that re-quired them.r When the proof system fails to verify a fact, one ap-proach is to figure out what more specific, supporting factsyou can provide that perhaps the proof system is failing toconsider. In this example, we went through this processthree times before arriving at a proof that the proof sys-tem could verify.

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInduction

Figure 9: Setting up an inductive argument to proveFiniteNatInduction .

3 Finite induction over naturalsIn this section we define and prove a theorem about finiteinduction over the natural numbers. We use this theoremlater in Section 5.

The ordinary form of induction is simple induction overthe naturals, in which a predicate P (i ) is proved to holdfor all i ∈ Nat . The TLA+ proof system has a theoremNatInduction , in the library module NaturalsInduction ,which encapsulates the simple inductive argument. Forany predicate P ( ), given the base case

P (0)and the inductive step

∀ i ∈ Nat : P (i )⇒ P (i + 1)NatInduction concludes

∀ i ∈ Nat : P (i )

Sometimes, however, we do not want or need to provethat predicate P (i ) holds for all i ∈ Nat , but rather onlyfor a finite range i ∈ m . . n . Such a situation often occurswhen proving things about sequences, for example.

We could, of course, always employ NatInduction insuch cases, by defining a more general predicate that holdsfor all i ∈ Nat . However, the proof of the inductive stepwould be cluttered up dealing with the transition of i as itcrosses into and out of the range m . . n .

A better approach is to define and prove a theoremFiniteNatInduction that explicitly deals with finite in-duction over the naturals. This approach moves the tran-sitional clutter into the proof of FiniteNatInduction andmakes all the proofs that need to use finite induction a bitcleaner. Figure 9 shows our theorem and the first steps inits proof.

4

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 32 / 52

Page 40: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from applying ConcatLeftCancel

Common mathematical properties of closure and associativity canbe important

I Humans are really good at utilizing these propertiesI Even though TLAPS considered the properties obvious, it was

unable to supply them automatically when trying to prove adeduction that required them

I In my experience, TLAPS has a really difficult time applyingassociativity

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 33 / 52

Page 41: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from applying ConcatLeftCancel

Common mathematical properties of closure and associativity canbe important

I Humans are really good at utilizing these propertiesI Even though TLAPS considered the properties obvious, it was

unable to supply them automatically when trying to prove adeduction that required them

I In my experience, TLAPS has a really difficult time applyingassociativity

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 33 / 52

Page 42: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from applying ConcatLeftCancel

Common mathematical properties of closure and associativity canbe important

I Humans are really good at utilizing these properties

I Even though TLAPS considered the properties obvious, it wasunable to supply them automatically when trying to prove adeduction that required them

I In my experience, TLAPS has a really difficult time applyingassociativity

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 33 / 52

Page 43: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from applying ConcatLeftCancel

Common mathematical properties of closure and associativity canbe important

I Humans are really good at utilizing these propertiesI Even though TLAPS considered the properties obvious, it was

unable to supply them automatically when trying to prove adeduction that required them

I In my experience, TLAPS has a really difficult time applyingassociativity

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 33 / 52

Page 44: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from applying ConcatLeftCancel

Common mathematical properties of closure and associativity canbe important

I Humans are really good at utilizing these propertiesI Even though TLAPS considered the properties obvious, it was

unable to supply them automatically when trying to prove adeduction that required them

I In my experience, TLAPS has a really difficult time applyingassociativity

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 33 / 52

Page 45: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from applying ConcatLeftCancel

Common mathematical properties of closure and associativity canbe important

I Humans are really good at utilizing these propertiesI Even though TLAPS considered the properties obvious, it was

unable to supply them automatically when trying to prove adeduction that required them

I In my experience, TLAPS has a really difficult time applyingassociativity

When TLAPS fails, try to figure out what specific fact you couldprovide that it is failing to consider

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 33 / 52

Page 46: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Finite induction over naturals

The ordinary form of induction is simple induction over thenaturals, in which a predicate P(i) is proved to hold for all i ∈ Nat.TLAPS has a libary theorem NatInduction, in the library moduleNaturalsInduction, that encapsulates the simple inductiveargument. For any P( ), given the base case

P(0)

and the inductive step

∀ i ∈ Nat : P(i)⇒ P(i + 1)

NatInduction concludes

∀ i ∈ Nat : P(i)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 34 / 52

Page 47: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Finite induction over naturals

The ordinary form of induction is simple induction over thenaturals, in which a predicate P(i) is proved to hold for all i ∈ Nat.

TLAPS has a libary theorem NatInduction, in the library moduleNaturalsInduction, that encapsulates the simple inductiveargument. For any P( ), given the base case

P(0)

and the inductive step

∀ i ∈ Nat : P(i)⇒ P(i + 1)

NatInduction concludes

∀ i ∈ Nat : P(i)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 34 / 52

Page 48: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Finite induction over naturals

The ordinary form of induction is simple induction over thenaturals, in which a predicate P(i) is proved to hold for all i ∈ Nat.TLAPS has a libary theorem NatInduction, in the library moduleNaturalsInduction, that encapsulates the simple inductiveargument. For any P( ), given the base case

P(0)

and the inductive step

∀ i ∈ Nat : P(i)⇒ P(i + 1)

NatInduction concludes

∀ i ∈ Nat : P(i)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 34 / 52

Page 49: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Finite induction over naturals - 2

Sometimes we do not want or need to prove that P(i) holds for alli ∈ Nat, but rather only for a finite range i ∈ m..n. This oftenoccurs when proving things about sequences.

In such cases, we could, of course, define a more general predicate

Q(i) ∆= i ∈ m..n⇒ P(i)

use NatInduction to prove that Q(i) holds for all i ∈ Nat and thendeduce what we want about P( ). But the proof would becluttered with the transitions of i into and out of m..n.A better approach is to define a prove and prove a theoremFiniteNatInduction that explicitly deals with finite induction overthe naturals.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 35 / 52

Page 50: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Finite induction over naturals - 2

Sometimes we do not want or need to prove that P(i) holds for alli ∈ Nat, but rather only for a finite range i ∈ m..n. This oftenoccurs when proving things about sequences.In such cases, we could, of course, define a more general predicate

Q(i) ∆= i ∈ m..n⇒ P(i)

use NatInduction to prove that Q(i) holds for all i ∈ Nat and thendeduce what we want about P( ). But the proof would becluttered with the transitions of i into and out of m..n.

A better approach is to define a prove and prove a theoremFiniteNatInduction that explicitly deals with finite induction overthe naturals.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 35 / 52

Page 51: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Finite induction over naturals - 2

Sometimes we do not want or need to prove that P(i) holds for alli ∈ Nat, but rather only for a finite range i ∈ m..n. This oftenoccurs when proving things about sequences.In such cases, we could, of course, define a more general predicate

Q(i) ∆= i ∈ m..n⇒ P(i)

use NatInduction to prove that Q(i) holds for all i ∈ Nat and thendeduce what we want about P( ). But the proof would becluttered with the transitions of i into and out of m..n.A better approach is to define a prove and prove a theoremFiniteNatInduction that explicitly deals with finite induction overthe naturals.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 35 / 52

Page 52: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Setting up the inductive argument

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉2. v ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉3. w ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉 QED BY 〈1〉1, 〈1〉2, 〈1〉3, ConcatLeftCancel unable to prove it

Figure 7: Third use attempt (still unsuccessful).

THEOREM UseConcatLeftCancel∆

=

ASSUMENEW S ,NEW u ∈ Seq(S ),NEW v ∈ Seq(S ),NEW w ∈ Seq(S ),NEW x ∈ Seq(S ),NEW m ∈ S ,NEW n ∈ S ,u ◦ 〈m , n〉 ◦ v ◦ x = u ◦ 〈m , n〉 ◦ w ◦ x

PROVEv ◦ x = w ◦ x

PROOF〈1〉1. u ◦ 〈m , n〉 ∈ Seq(S ) OBVIOUS ◦ closed〈1〉2. v ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉3. w ◦ x ∈ Seq(S ) OBVIOUS ◦ closed〈1〉4. u ◦ 〈m , n〉 ◦ (v ◦ x ) = u ◦ 〈m , n〉 ◦ (w ◦ x ) OBVIOUS〈1〉 QED BY 〈1〉1, 〈1〉2, 〈1〉3, 〈1〉4, ConcatLeftCancel

Figure 8: Fourth use attempt (successful).

our theorem, and apply it.Lessons from this example:

r The application of ConcatLeftCancel shows how im-portant are the common mathematical properties of clo-sure and associativity. Humans are good at utilizing theseproperties when proving deductions. Even though theTLA+ proof system considered applications of closureand associativity as obvious, it was unable to supply themautomatically when trying to prove a deduction that re-quired them.r When the proof system fails to verify a fact, one ap-proach is to figure out what more specific, supporting factsyou can provide that perhaps the proof system is failing toconsider. In this example, we went through this processthree times before arriving at a proof that the proof sys-tem could verify.

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInduction

Figure 9: Setting up an inductive argument to proveFiniteNatInduction .

3 Finite induction over naturalsIn this section we define and prove a theorem about finiteinduction over the natural numbers. We use this theoremlater in Section 5.

The ordinary form of induction is simple induction overthe naturals, in which a predicate P (i ) is proved to holdfor all i ∈ Nat . The TLA+ proof system has a theoremNatInduction , in the library module NaturalsInduction ,which encapsulates the simple inductive argument. Forany predicate P ( ), given the base case

P (0)and the inductive step

∀ i ∈ Nat : P (i )⇒ P (i + 1)NatInduction concludes

∀ i ∈ Nat : P (i )

Sometimes, however, we do not want or need to provethat predicate P (i ) holds for all i ∈ Nat , but rather onlyfor a finite range i ∈ m . . n . Such a situation often occurswhen proving things about sequences, for example.

We could, of course, always employ NatInduction insuch cases, by defining a more general predicate that holdsfor all i ∈ Nat . However, the proof of the inductive stepwould be cluttered up dealing with the transition of i as itcrosses into and out of the range m . . n .

A better approach is to define and prove a theoremFiniteNatInduction that explicitly deals with finite in-duction over the naturals. This approach moves the tran-sitional clutter into the proof of FiniteNatInduction andmakes all the proofs that need to use finite induction a bitcleaner. Figure 9 shows our theorem and the first steps inits proof.

4

Define the more generalpredicate Q( )

Use a SUFFICES to change thegoal to ∀ i ∈ Nat : Q(i)

State the base case andinductive step as facts

Hide the definition of theinductive predicate Q( )

Appeal to NatInduction

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 36 / 52

Page 53: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Completing the subproof of the inductive step

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈2〉1. SUFFICES ASSUME NEW i ∈ Nat , Q(i )

PROVE Q(i + 1) OBVIOUS〈2〉2.CASE i + 1 ∈ (m + 1) . . n BY 〈2〉1, 〈2〉2〈2〉3.CASE i + 1 = m BY 〈2〉3〈2〉4.CASE i + 1 < m . . n BY 〈2〉4〈2〉 QED BY 〈2〉2, 〈2〉3, 〈2〉4

Figure 10: Proof of the inductive step.

In the proof we define a new predicateQ(i ) ∆

= i ∈ m . . n ⇒ P (i )It suffices to prove that Q(i ) holds for all i ∈ Nat . In step〈1〉1 we assert the base case and in step 〈1〉2 we assert theinductive step. The base case is obvious since if m = 0we have P (m). Given the base case and the inductivestep, NatInduction can conclude that Q(i ) holds for alli ∈ Nat , which is the current goal.

It is good practice, when writing inductive proofs, tohide the definition of the induction predicate, Q in thiscase, before appealing to NatInduction . In order to ap-ply NatInduction the TLA+ proof system does not needto know the definition of the induction predicate, and, in-deed, if the definition is at all complicated, the proof sys-tem will tend to get lost in it and be unable to verify theconclusion. With the definition hidden, the proof systemsees only an uninterpreted operator symbol appearing inthe exact form of an inductive argument, and the argumentwill be verified.

More generally, whenever applying a proof rule con-taining a NEW Q( ) that must be instantiated with someoperator Op, you should hide the definition of Op.

Now we prove the inductive step, as shown in Fig-ure 10. The first thing we do is to disassemble the uni-versal quantified implication. It suffices to assume thatwe have a new symbol i ∈ Nat , that we have the hypoth-esis Q(i ), and that we have to prove Q(i + 1). This is step〈2〉1. Then we use a case analysis.

Step 〈2〉2 handles the case of i + 1 ∈ (m + 1) . . n . Inthis case, Q(i ) from the inductive hypothesis implies P (i )which implies P (i + 1) which implies Q(i + 1).

Step 〈2〉3 handles the case of i + 1 = m . In this case,Q(i + 1) follows from P (m).

Step 〈2〉4 handles the case of i + 1 < m . . n . In thiscase, Q(i + 1) holds directly from the definition of Q .Since the three cases cover every possibility, the proof ofthe inductive step is complete.

This completes the proof of the theorem. Figure 11shows the complete proof.

I slid over the statement that “the three cases coverevery possibility” pretty fast. Like everything else in a

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈2〉1. SUFFICES ASSUME NEW i ∈ Nat , Q(i )

PROVE Q(i + 1) OBVIOUS〈2〉2.CASE i + 1 ∈ (m + 1) . . n BY 〈2〉1, 〈2〉2〈2〉3.CASE i + 1 = m BY 〈2〉3〈2〉4.CASE i + 1 < m . . n BY 〈2〉4〈2〉 QED BY 〈2〉2, 〈2〉3, 〈2〉4〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInductionFigure 11: Complete proof of FiniteNatInduction .

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1) OBVIOUS〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInductionFigure 12: Simplified proof of FiniteNatInduction .

machine-checked formal proof, the proof system will haveto be convinced of this fact. To complete the argument bycases, there is an obligation to show that

∨ i + 1 ∈ (m + 1) . . n∨ i + 1 = m∨ i + 1 < m . . n

This follows from the fact that i , m , and n are all naturalnumbers. In this example, the proof system was able todischarge this obligation automatically. But in more com-plicated examples, you may have to prove the coveragefact explicitly.

I mentioned before that it is always a good idea to

5

Use SUFFICES ASSUMEPROVE to disassemble theuniversal quantifier and theimplication

Use CASE to perform a caseanalysis

The cases must cover allpossibilities

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 37 / 52

Page 54: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Simplified proof of FiniteNatInduction

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈2〉1. SUFFICES ASSUME NEW i ∈ Nat , Q(i )

PROVE Q(i + 1) OBVIOUS〈2〉2.CASE i + 1 ∈ (m + 1) . . n BY 〈2〉1, 〈2〉2〈2〉3.CASE i + 1 = m BY 〈2〉3〈2〉4.CASE i + 1 < m . . n BY 〈2〉4〈2〉 QED BY 〈2〉2, 〈2〉3, 〈2〉4

Figure 10: Proof of the inductive step.

In the proof we define a new predicateQ(i ) ∆

= i ∈ m . . n ⇒ P (i )It suffices to prove that Q(i ) holds for all i ∈ Nat . In step〈1〉1 we assert the base case and in step 〈1〉2 we assert theinductive step. The base case is obvious since if m = 0we have P (m). Given the base case and the inductivestep, NatInduction can conclude that Q(i ) holds for alli ∈ Nat , which is the current goal.

It is good practice, when writing inductive proofs, tohide the definition of the induction predicate, Q in thiscase, before appealing to NatInduction . In order to ap-ply NatInduction the TLA+ proof system does not needto know the definition of the induction predicate, and, in-deed, if the definition is at all complicated, the proof sys-tem will tend to get lost in it and be unable to verify theconclusion. With the definition hidden, the proof systemsees only an uninterpreted operator symbol appearing inthe exact form of an inductive argument, and the argumentwill be verified.

More generally, whenever applying a proof rule con-taining a NEW Q( ) that must be instantiated with someoperator Op, you should hide the definition of Op.

Now we prove the inductive step, as shown in Fig-ure 10. The first thing we do is to disassemble the uni-versal quantified implication. It suffices to assume thatwe have a new symbol i ∈ Nat , that we have the hypoth-esis Q(i ), and that we have to prove Q(i + 1). This is step〈2〉1. Then we use a case analysis.

Step 〈2〉2 handles the case of i + 1 ∈ (m + 1) . . n . Inthis case, Q(i ) from the inductive hypothesis implies P (i )which implies P (i + 1) which implies Q(i + 1).

Step 〈2〉3 handles the case of i + 1 = m . In this case,Q(i + 1) follows from P (m).

Step 〈2〉4 handles the case of i + 1 < m . . n . In thiscase, Q(i + 1) holds directly from the definition of Q .Since the three cases cover every possibility, the proof ofthe inductive step is complete.

This completes the proof of the theorem. Figure 11shows the complete proof.

I slid over the statement that “the three cases coverevery possibility” pretty fast. Like everything else in a

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1)〈2〉1. SUFFICES ASSUME NEW i ∈ Nat , Q(i )

PROVE Q(i + 1) OBVIOUS〈2〉2.CASE i + 1 ∈ (m + 1) . . n BY 〈2〉1, 〈2〉2〈2〉3.CASE i + 1 = m BY 〈2〉3〈2〉4.CASE i + 1 < m . . n BY 〈2〉4〈2〉 QED BY 〈2〉2, 〈2〉3, 〈2〉4〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInductionFigure 11: Complete proof of FiniteNatInduction .

THEOREM FiniteNatInduction∆

=

ASSUMENEW P ( ), predicateNEW m ∈ Nat , startNEW n ∈ Nat , limitP (m), base case∀ i ∈ m . . (n − 1) : P (i )⇒ P (i + 1) finite ind hyp

PROVE ∀ i ∈ m . . n : P (i )PROOF〈1〉 DEFINE Q(i ) ∆

= i ∈ m . . n ⇒ P (i )〈1〉 SUFFICES ∀ i ∈ Nat : Q(i ) OBVIOUS

base case

〈1〉1. Q(0) OBVIOUS

inductive step

〈1〉2. ∀ i ∈ Nat : Q(i )⇒ Q(i + 1) OBVIOUS〈1〉 HIDE DEF Q hide defn of induction predicate〈1〉 QED BY 〈1〉1, 〈1〉2, NatInductionFigure 12: Simplified proof of FiniteNatInduction .

machine-checked formal proof, the proof system will haveto be convinced of this fact. To complete the argument bycases, there is an obligation to show that

∨ i + 1 ∈ (m + 1) . . n∨ i + 1 = m∨ i + 1 < m . . n

This follows from the fact that i , m , and n are all naturalnumbers. In this example, the proof system was able todischarge this obligation automatically. But in more com-plicated examples, you may have to prove the coveragefact explicitly.

I mentioned before that it is always a good idea to

5

It turns out that TLAPS thinksthat the inductive step isobvious. We neglected tocheck this before plunginginto the case analysis. Hencethe proof can be simplifiedconsiderably.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 38 / 52

Page 55: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goalUse SUFFICES ASSUME PROVE to disassemble universalquantifiers and implicationsUse CASE statements to disassemble the current goal into cases

I TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 56: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goalUse SUFFICES ASSUME PROVE to disassemble universalquantifiers and implicationsUse CASE statements to disassemble the current goal into cases

I TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 57: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goalUse SUFFICES ASSUME PROVE to disassemble universalquantifiers and implicationsUse CASE statements to disassemble the current goal into cases

I TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 58: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goal

Use SUFFICES ASSUME PROVE to disassemble universalquantifiers and implicationsUse CASE statements to disassemble the current goal into cases

I TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 59: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goalUse SUFFICES ASSUME PROVE to disassemble universalquantifiers and implications

Use CASE statements to disassemble the current goal into casesI TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 60: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goalUse SUFFICES ASSUME PROVE to disassemble universalquantifiers and implicationsUse CASE statements to disassemble the current goal into cases

I TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 61: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Lessons from proving FiniteNatInduction

Hide the definition of the induction predicate before appealing tothe induction theorem

I More generally, when applying a proof rule containing a NEW Q( )that must be instantiated with some operator Op, you should hidethe definition of Op

Use SUFFICES to change the goalUse SUFFICES ASSUME PROVE to disassemble universalquantifiers and implicationsUse CASE statements to disassemble the current goal into cases

I TLAPS will have to be convinced that all cases are coveredI Often it can figure this out on its own, but sometimes you need to

present the fact explicitly

Always check to see if TLAPS can prove a fact (given the necessarypredicate facts) before plunging into a subproof

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 39 / 52

Page 62: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Outline

1 TLAPS Basics

2 Tips and Best Practices for Using TLAPS

3 Temporal Reasoning in TLAPS

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 40 / 52

Page 63: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal proofs in TLAPS

A standard safety proofI validation of a temporal formulaI mostly action reasoningI temporal reasoning for validating

QED step

In this talk:I Why

quantified temporal formulas can be proved using

first-order and propositional temporal backends

I Howto write the proofs correctly

I Whichformulas can be proved using that

F Note: TLA+ is not complete forquantified temporal logic.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 41 / 52

Page 64: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal proofs in TLAPS

A standard safety proofI validation of a temporal formulaI mostly action reasoningI temporal reasoning for validating

QED stepIn this talk:

I Whyquantified temporal formulas can be proved using

first-order and propositional temporal backends

I Howto write the proofs correctly

I Whichformulas can be proved using that

F Note: TLA+ is not complete forquantified temporal logic.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 41 / 52

Page 65: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal proofs in TLAPS

A standard safety proofI validation of a temporal formulaI mostly action reasoningI temporal reasoning for validating

QED stepIn this talk:

I Whyquantified temporal formulas can be proved using

first-order and propositional temporal backends

I Howto write the proofs correctly

I Whichformulas can be proved using that

F Note: TLA+ is not complete forquantified temporal logic.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 41 / 52

Page 66: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal proofs in TLAPS

A standard safety proofI validation of a temporal formulaI mostly action reasoningI temporal reasoning for validating

QED stepIn this talk:

I Whyquantified temporal formulas can be proved using

first-order and propositional temporal backends

I Howto write the proofs correctly

I Whichformulas can be proved using that

F Note: TLA+ is not complete forquantified temporal logic.

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 41 / 52

Page 67: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

Semantics

I Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 68: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program Executions

I States

I Behaviors and suffixesSyntax

I Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 69: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI States

I Behaviors and suffixesSyntax

I Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 70: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressions

I State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 71: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressions

I State expressions

I Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 72: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressions

I Action expressions

I Temporal expressionsLogic

I First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 73: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressionsI Action expressions

I Temporal expressionsLogic

I First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 74: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]

I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 75: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]

I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 76: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 77: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Temporal concepts in TLA+

SemanticsI Program ExecutionsI StatesI Behaviors and suffixes

SyntaxI Constant expressionsI State expressionsI Action expressionsI Temporal expressions

LogicI First-order [1]I Temporal

F PTL

[1] Coalescing: Syntactic Abstraction for Reasoning in First-Order Modal Logics

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 42 / 52

Page 78: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Breaking temporal formulas into action formulas

Proving quantified temporal formulas from action formulas andpropositional temporal rules.

I find a temporal ruleI verify the ruleI understand failures

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 43 / 52

Page 79: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Breaking temporal formulas into action formulas

Proving quantified temporal formulas from action formulas andpropositional temporal rules.

I find a temporal rule

I verify the ruleI understand failures

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 43 / 52

Page 80: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Breaking temporal formulas into action formulas

Proving quantified temporal formulas from action formulas andpropositional temporal rules.

I find a temporal ruleI verify the rule

I understand failures

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 43 / 52

Page 81: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Breaking temporal formulas into action formulas

Proving quantified temporal formulas from action formulas andpropositional temporal rules.

I find a temporal ruleI verify the ruleI understand failures

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 43 / 52

Page 82: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

How to find the rules

Safety properties - based onvariations of the inductiveinvariant rule:

Other properties - other rules

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 44 / 52

Page 83: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

How to find the rules

Safety properties - based onvariations of the inductiveinvariant rule:

Other properties - other rules

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 44 / 52

Page 84: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

How to find the rules

Safety properties - based onvariations of the inductiveinvariant rule:

Other properties - other rules

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 44 / 52

Page 85: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

How to find the rules

Safety properties - based onvariations of the inductiveinvariant rule:

Other properties - other rules

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 44 / 52

Page 86: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

How to find the rules

Safety properties - based onvariations of the inductiveinvariant rule:

Other properties - other rules

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 44 / 52

Page 87: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Are the rules sound?

Rule is an instance of the PTL rule:

Success of PTL backend verifies this

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 45 / 52

Page 88: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Are the rules sound?

Rule is an instance of the PTL rule:

Success of PTL backend verifies this

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 45 / 52

Page 89: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Are the rules sound?

Rule is an instance of the PTL rule:

Success of PTL backend verifies this

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 45 / 52

Page 90: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Understanding failures

Consider this valid lemma

which seems to be an instance of the PTL rule:

But it is not, why?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 46 / 52

Page 91: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Understanding failures

Consider this valid lemmawhich seems to be an instance of the PTL rule:

But it is not, why?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 46 / 52

Page 92: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Understanding failures

Consider this valid lemmawhich seems to be an instance of the PTL rule:

But it is not, why?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 46 / 52

Page 93: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Since 〈1〉2 holds in allbehaviours, it can beboxed

This is callednecessitationThe PTL rules normallyrequires the applicationof necessitation on theaction steps

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 47 / 52

Page 94: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Since 〈1〉2 holds in allbehaviours, it can beboxed

This is callednecessitationThe PTL rules normallyrequires the applicationof necessitation on theaction steps

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 47 / 52

Page 95: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Since 〈1〉2 holds in allbehaviours, it can beboxedThis is callednecessitation

The PTL rules normallyrequires the applicationof necessitation on theaction steps

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 47 / 52

Page 96: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Since 〈1〉2 holds in allbehaviours, it can beboxedThis is callednecessitationThe PTL rules normallyrequires the applicationof necessitation on theaction steps

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 47 / 52

Page 97: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Spec

Spec is assumed whenproving the proof steps

〈1〉2 doesn’t hold in allbehavioursNecessitation is notappliedNote: There is aworkaround

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 48 / 52

Page 98: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Spec

Spec is assumed whenproving the proof steps

〈1〉2 doesn’t hold in allbehavioursNecessitation is notappliedNote: There is aworkaround

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 48 / 52

Page 99: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Spec

Spec is assumed whenproving the proof steps〈1〉2 doesn’t hold in allbehaviours

Necessitation is notappliedNote: There is aworkaround

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 48 / 52

Page 100: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Spec

Spec is assumed whenproving the proof steps〈1〉2 doesn’t hold in allbehavioursNecessitation is notapplied

Note: There is aworkaround

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 48 / 52

Page 101: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation

Spec

Spec is assumed whenproving the proof steps〈1〉2 doesn’t hold in allbehavioursNecessitation is notappliedNote: There is aworkaround

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 48 / 52

Page 102: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions

Consider the following clearlyinvalid claim

The rule is again an instanceof the previous PTL ruleThe two hypothesis are validbut the rule is not soundWhy? Necessitation fails for〈1〉2Confusing? Necessitationfailures are reported in theobligation window

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 49 / 52

Page 103: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions

Consider the following clearlyinvalid claimThe rule is again an instanceof the previous PTL rule

The two hypothesis are validbut the rule is not soundWhy? Necessitation fails for〈1〉2Confusing? Necessitationfailures are reported in theobligation window

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 49 / 52

Page 104: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions

Consider the following clearlyinvalid claimThe rule is again an instanceof the previous PTL ruleThe two hypothesis are validbut the rule is not soundWhy? Necessitation fails for〈1〉2

Confusing? Necessitationfailures are reported in theobligation window

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 49 / 52

Page 105: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions

Consider the following clearlyinvalid claimThe rule is again an instanceof the previous PTL ruleThe two hypothesis are validbut the rule is not soundWhy? Necessitation fails for〈1〉2Confusing? Necessitationfailures are reported in theobligation window

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 49 / 52

Page 106: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions II

Now, the claim is valid, even ifin a trivial way

The proof is idential to theprevious oneThis time, necessitation isappliedWhat is the difference?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 50 / 52

Page 107: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions II

Now, the claim is valid, even ifin a trivial wayThe proof is idential to theprevious one

This time, necessitation isappliedWhat is the difference?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 50 / 52

Page 108: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions II

Now, the claim is valid, even ifin a trivial wayThe proof is idential to theprevious oneThis time, necessitation isapplied

What is the difference?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 50 / 52

Page 109: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Necessitation and assumptions II

Now, the claim is valid, even ifin a trivial wayThe proof is idential to theprevious oneThis time, necessitation isappliedWhat is the difference?

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 50 / 52

Page 110: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Boxable assumptions

Assumptions P, such that P⇔ 2P, allow for necessitation.

We determine this using the following is box algorithm:

An assumption proved in the scope of a non-boxed assumption isconsidered as non-boxed as well

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 51 / 52

Page 111: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Boxable assumptions

Assumptions P, such that P⇔ 2P, allow for necessitation.We determine this using the following is box algorithm:

An assumption proved in the scope of a non-boxed assumption isconsidered as non-boxed as well

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 51 / 52

Page 112: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Boxable assumptions

Assumptions P, such that P⇔ 2P, allow for necessitation.We determine this using the following is box algorithm:

An assumption proved in the scope of a non-boxed assumption isconsidered as non-boxed as well

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 51 / 52

Page 113: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Conclusion

TLA+ proofs for quantified temporal formulas - Why and How

Which:I for all safety propertiesI for liveness properties - still require:

F reasoning about ENABLEDF some proofs require full quantified temporal reasoning - Ex:∀x.2P(x)⇔ 2∀x.P(x)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 52 / 52

Page 114: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Conclusion

TLA+ proofs for quantified temporal formulas - Why and HowWhich:

I for all safety propertiesI for liveness properties - still require:

F reasoning about ENABLEDF some proofs require full quantified temporal reasoning - Ex:∀x.2P(x)⇔ 2∀x.P(x)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 52 / 52

Page 115: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Conclusion

TLA+ proofs for quantified temporal formulas - Why and HowWhich:

I for all safety properties

I for liveness properties - still require:F reasoning about ENABLEDF some proofs require full quantified temporal reasoning - Ex:∀x.2P(x)⇔ 2∀x.P(x)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 52 / 52

Page 116: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Conclusion

TLA+ proofs for quantified temporal formulas - Why and HowWhich:

I for all safety propertiesI for liveness properties - still require:

F reasoning about ENABLEDF some proofs require full quantified temporal reasoning - Ex:∀x.2P(x)⇔ 2∀x.P(x)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 52 / 52

Page 117: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Conclusion

TLA+ proofs for quantified temporal formulas - Why and HowWhich:

I for all safety propertiesI for liveness properties - still require:

F reasoning about ENABLED

F some proofs require full quantified temporal reasoning - Ex:∀x.2P(x)⇔ 2∀x.P(x)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 52 / 52

Page 118: A Tutorial Introduction to tlaps · A Tutorial Introduction to TLAPS Jael Kriener 1 Tom Rodeheffer 2 Tomer Libal 1 1 2 TLA+ Community Event, ABZ 2014 Toulouse, June 3, 2014 Jael K.,

Conclusion

TLA+ proofs for quantified temporal formulas - Why and HowWhich:

I for all safety propertiesI for liveness properties - still require:

F reasoning about ENABLEDF some proofs require full quantified temporal reasoning - Ex:∀x.2P(x)⇔ 2∀x.P(x)

Jael K., Tom R. and Tomer L. TLAPS Tutorial Toulouse, June 2014 52 / 52