-------------------------------- MODULE Chain -------------------
EXTENDS Sequences
CONSTANT BLOCKS \* The set of blocks
VARIABLE chain, bState \* bState[b] is the state of block b.
TypeOK == bState \in [BLOCKS -> {"ADDED", "NOTADDED"}]
Init == /\ bState = [b \in BLOCKS |-> "NOTADDED"]
/\ chain = {"genesis"}
canAdd == \A b \in BLOCKS : bState[b] \in {"NOTADDED"}
notAdded == \A b \in BLOCKS : bState[b] # "ADDED"
Add(b) == /\ bState[b] = "NOTADDED"
/\ canAdd
/\ chain' = Append(chain, ?)
/\ bState' = [bState EXCEPT ![b] = "ADDED"]
Next == \E b \in BLOCKS : Add(b)
=================================================================