Skip to content

Instantly share code, notes, and snippets.

@sadraskol
Created November 12, 2020 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadraskol/8da8360f8d132ced1ffbd8540033314d to your computer and use it in GitHub Desktop.
Save sadraskol/8da8360f8d132ced1ffbd8540033314d to your computer and use it in GitHub Desktop.
-------------------------- MODULE DullReservation --------------------------
EXTENDS Naturals, FiniteSets
VARIABLE reservations
Coaches == { "A", "B" }
SeatNumbers == 1..10
Seats == Coaches \X SeatNumbers
70PercentTrainOccupation == (70 * Cardinality(Seats)) \div 100
----
Reserve(seatCount) ==
/\ Cardinality(UNION reservations) + seatCount <= 70PercentTrainOccupation
/\ \E seats \in SUBSET Seats:
/\ Cardinality(seats) = seatCount
/\ reservations' = reservations \union {seats}
----
Init == reservations = {}
Next == \E seatCount \in 1..Cardinality(Seats): Reserve(seatCount)
----
TypeCheck == reservations \in SUBSET SUBSET Seats
AtMost70PercentTrainOccupation == Cardinality(UNION reservations) <= 70PercentTrainOccupation
=============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment