module protocol
b : [1..L];
n : [0..N-1];
phase : [1..4];
party : [1..2];
[receiveB] phase=1 & party=1 -> (party'=2);
[receiveA] phase=1 & party=2 & n<N-1 -> (party'=1) & (n'=n+1);
[receiveA] phase=1 & party=2 & n=N-1 -> (party'=1) & (phase'=2) & (n'=0);
[receiveB] !kB & (phase=2 | phase=3) & party=1 & n<N-1-> (n'=n+1);
[receiveB] !kB & phase=2 & party=1 & n=N-1 -> (phase'=3) & (n'=0);
[receiveB] !kB & phase=3 & party=1 & n=N-1 -> (phase'=2) & (party'=2) & (n'=0);
[receiveA] !kB & (phase=2 | phase=3) & party=2 & n<N-1 -> (n'=n+1);
[receiveA] !kB & phase=2 & party=2 & n=N-1 -> (phase'=3) & (n'=0);
[receiveA] !kB & phase=3 & party=2 & n=N-1 & b<L -> (phase'=2) & (party'=1) & (n'=0) & (b'=b+1);
[receiveA] !kB & phase=3 & party=2 & n=N-1 & b=L -> (phase'=4);
[finish] kB & phase<4 -> (phase'=4);
[] phase=4 -> (phase'=4);
endmodule