Created
March 23, 2019 20:23
-
-
Save nrinaudo/05013686b3639288123608630f4b23e0 to your computer and use it in GitHub Desktop.
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
EXTENDS Integers, TLC, Sequences | |
CONSTANTS Books, | |
People, | |
NumCopies | |
ASSUME NumCopies \in Nat \ {0} | |
PT == INSTANCE PT | |
(*--algorithm library | |
variables library \in [Books -> 1..NumCopies] | |
define | |
AvailableBooks == {b \in Books: library[b] > 0} | |
end define; | |
fair process person \in People | |
variables books = {}, | |
wants \in SUBSET Books; | |
begin | |
Person: | |
either \* Checkout | |
with b \in AvailableBooks \ books do | |
library[b] := library[b] - 1; | |
books := books \union b; | |
wants := wants \ {b}; | |
end with; | |
or \* Return | |
with b \in books do | |
library[b] := library[b] + 1; | |
books := books \ b; | |
end with; | |
end either; | |
goto Person; | |
end process; | |
end algorithm;*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The mistakes are line 25 and 32, where it should read
{b}
, notb
.Running this yields:
Evaluating
{} \union b3
in the Evaluate constant expression tab yields: