|
2 | 2 |
|
3 | 3 | A TLA⁺ specification of a simple deli ordering system with a bounded ticket-queue model. |
4 | 4 |
|
5 | | -The spec models customers arriving and being served sequentially. Customers arrive (bounded by `MaxArrivals`), receive a ticket number, join an order queue, get assigned to a worker, receive service, and the system resets to serve the next customer. The system cycles through states: Idle → TakingOrder → PreparingOrder → Serving → ReturnToIdle. |
| 5 | +The spec models customers arriving and being served sequentially. Customers arrive (bounded by `MaxArrivals`), receive a ticket number, join an order queue, get assigned to a worker, receive service, and the system resets to serve the next customer. The system progresses through four states: Idle, TakingOrder, PreparingOrder, and Serving; transitions include ReturnToIdle which moves from Serving back to Idle. |
6 | 6 |
|
7 | 7 | ## Design |
8 | 8 |
|
9 | | -- **Ticket-based ordering**: Customers get monotonically increasing ticket numbers as they arrive |
10 | | -- **Queue discipline**: Customers are served in FIFO order from the queue |
11 | 9 | - **Bounded arrivals**: The `MaxArrivals` constant limits customer arrivals for tractable model checking |
12 | | -- **State machine with return cycle**: The system explicitly cycles back to Idle after each service, preventing deadlock and allowing new orders |
| 10 | +- **Queue discipline**: Customers join the orderQueue in FIFO order |
| 11 | +- **Worker assignment**: Any available worker processes the next customer from the queue |
| 12 | +- **Cyclic state machine**: The system explicitly cycles back to Idle after each service, preventing deadlock |
13 | 13 |
|
14 | 14 | ## Properties Verified |
15 | 15 |
|
16 | 16 | The specification includes three safety invariants, all verified by TLC: |
17 | 17 |
|
18 | | -1. **TypeOK**: State variables maintain correct types throughout execution |
19 | | -2. **ValidStates**: The system never enters an undefined state |
20 | | -3. **MutualExclusion**: At most one customer is being served at any time; idle workers cannot be assigned |
| 18 | +1. **TypeOK**: All state variables maintain their declared types throughout execution |
| 19 | +2. **ValidStates**: The system's state variable remains one of the four allowed values |
| 20 | +3. **ConsistentIdle**: When in the Idle state, no customer or worker is assigned |
21 | 21 |
|
22 | | -The `.tla` file includes formal THEOREM declarations for each property. With `MaxArrivals = 2` and `Processes = {p1, p2, p3}`, the model contains **30 distinct states** and completes exhaustive model checking in under 1 second. |
| 22 | +With `MaxArrivals = 2` and `Processes = {p1, p2, p3}`, the model contains **45 distinct states** and completes exhaustive model checking in under 1 second. |
0 commit comments