13.07.2015 Views

Proving the Correctness of Distributed Algorithms using TLA

Proving the Correctness of Distributed Algorithms using TLA

Proving the Correctness of Distributed Algorithms using TLA

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Khushboo KanjaniP1: while true doif x 1 = x n <strong>the</strong>nx 1 := (x 1 + 1)mod(n + 1)endendP i (i ≠ 1) :while true doifx i ≠ x i−1 <strong>the</strong>nx i := x i−1endendAlgorithm 1: Dijkstra self-stabilizing algorithm for MEExample: Here we give a <strong>TLA</strong> specification <strong>of</strong> <strong>the</strong> famous Dijkstra’s selfstabilizingalgorithm for mutual exclusion in a ring described in Algorithm1. The notations used here are explained in Figure 1. Equation 1 describes<strong>the</strong> initial condition <strong>of</strong> <strong>the</strong> variables. Equation 2 states that ∀i ∈ [0, N]i ≠ 1if <strong>the</strong> value <strong>of</strong> x i is not equal to that <strong>of</strong> its left neighbor, it is assigned thatvalue when process P i is activated. For P 1 , equation 3 states that <strong>the</strong> value<strong>of</strong> x 1 is incremented if its value is equal to x n . In equation 4, w defines<strong>the</strong> state function <strong>of</strong> all <strong>the</strong> variables in <strong>the</strong> program. These <strong>TLA</strong> formulasC 1 , C 2 , ....C n describe <strong>the</strong> behavior <strong>of</strong> <strong>the</strong> processes P 1 , P 2 , ....P n respectively.All possible executions <strong>of</strong> <strong>the</strong> program satisfy <strong>the</strong> temporal formula definedin equation 6.Init φ ≡ ∀i ∈ n, 0 ≤ x i ≤ n (1)∀i ∈ [0, N]i ≠ 1, C i ≡ (x i ≠ x i−1 ) ∧ (x ′ i = x i−1 ) ∧ Unchanged < AllBut(x i ) >(2)C 1 ≡ (x 1 = x n ) ∧ (x ′ 1 = (x 1 + 1)mod(n + 1)) ∧ Unchanged < AllBut(x 1 ) >(3)w =< x 1 , x 2 , ........., x n > (4)C ≡ C 1 ∨ C 2 ∨ ........ ∨ C n (5)φ ≡ Init φ ∧ □[C] w (6)CPSC 689-608 Spring 2007 Report Draft

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!