Created
August 17, 2024 23:41
-
-
Save lorin/c2251d4349b0ec8e5da84bfd52cb0372 to your computer and use it in GitHub Desktop.
A simple queue model
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
\* Queue model where changes happen in each state | |
---- MODULE queue1 ---- | |
EXTENDS Sequences | |
CONSTANT Val, N | |
VARIABLES op,arg,rval,d | |
none == CHOOSE v : v \notin Val | |
Init == /\ op = "enq" | |
/\ arg \in Val | |
/\ rval = "ok" | |
/\ d = <<arg>> | |
Enq == /\ Len(d) < N | |
/\ op' = "enq" | |
/\ arg' \in Val | |
/\ rval' = none | |
/\ d' = Append(d, arg') | |
Deq == /\ d /= <<>> | |
/\ op' = "deq" | |
/\ arg' = none | |
/\ rval' = Head(d) | |
/\ d' = Tail(d) | |
Next == Enq \/ Deq | |
==== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment