OTS/CafeOBJ method
The protocol consists of two processes, Sender and Receiver, each having a data buffer and a one-bit state. Sender and Receiver use two channels to communicate with each other, as they do not share any common memory: (a) a data channel from Sender to Receiver for sending bit-packet pairs, and (b) an acknowledgement channel from Receiver to Sender for sending single bits for confirmation. The protocol works as follows:
< bit, pac >
to the data channel, where bit
is the Sender's bit and pac
is the Sender's data to transmit.
If the Sender receives bit
from Receiver over the acknowledgement channel, then that is a confirmation that the packet sent has been delivered.
In that case, Sender flips its bit and select the next packet to send. < bit, pac >
such that bit
is different from its bit, then it stores pac
and flips its bit. For the ABP we are interested in verifying the following safety property: all messages from Sender are successfully delivered to Receiver, in the correct order, despite the fact that the two communication channels may lose or duplicate messages.
This is achieved in three main steps.
We prove the following four invariants by simulteneous induction.
ceq [inv1]: B' = bit1(S) if C1,< B,P >,C2,< B',P' >,C3 := channel1(S) /\ B = bit1(S)
ceq [inv2]: B = bit1(S) if C1,< B,P >,C2 := channel1(S) /\ bit2(S) = bit1(S)
ceq [inv3]: bit2(S) = bit1(S) if D1,B,D2 := channel2(S) /\ B = bit1(S)
ceq [inv4]: B' = bit1(S) if D1,B,D2,B',D3 := channel2(S) /\ B = bit1(S)
See inv.maude for the full proof.
We prove another invariant, inv5, using inv1, inv2, inv3 and inv4 as lemmas.
< B, P >
such that B
is Sender's bit, then P
is Sender's current packet.
ceq [inv5]: P1 = pac(next(S)) if C1,< B,P >,C2 := channel1(S) /\ B1 = bit1(S)
See inv5.maude for the full proof.
The safety property of interest is formalized as the conjunction of two goals.
ceq [goal1]: mk(next(S:Sys)) = list(S:Sys) if bit2(S:Sys) = bit1(S:Sys)
ceq [goal2]: mk(next(S:Sys)) = pac(next(S:Sys)),list(S:Sys) if not bit2(S:Sys) = bit1(S:Sys)
See goal.maude for the full proof.