Created
November 3, 2016 16:12
-
-
Save mdmarek/15ad6f68d10f584b9dd741b3bee2a6ac to your computer and use it in GitHub Desktop.
TLA+ Channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INIT | |
Init | |
NEXT | |
Next | |
INVARIANT | |
TypeOK | |
CONSTANTS | |
Data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- MODULE Chan ---- | |
EXTENDS Integers, TLC | |
CONSTANT Data | |
VARIABLE chan | |
TypeOK == chan \in [val: Data, rdy: {0,1}, ack: {0,1}] | |
Init == /\ TypeOK | |
/\ chan.ack = chan.rdy | |
Tx(d) == /\ chan.rdy = chan.ack | |
/\ chan' = [chan EXCEPT !.val = d, !.rdy = 1 - @] | |
Rx == /\ chan.rdy /= chan.ack | |
/\ chan' = [chan EXCEPT !.ack = 1 - @] | |
Next == (\E d \in Data : Tx(d)) \/ Rx | |
Spec == Init /\ [][Next]_chan | |
---- | |
THEOREM Spec => []TypeOK | |
==== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment