Bakery Algorithm

This example provides a formal specification of Lamport's Bakery algorithm, a protocol for ensuring mutual exclusion among concurrent processes. Each process selects a ticket number, and access to the critical section is granted in increasing order, with ties broken by process identifiers. This mechanism ensures that no two processes enter the critical section simultaneously while preserving fairness.

Verification

This case study illustrates invariant generation for Lamport's Bakery protocol. Starting from symbolic initial states, DM-Check generates successive frontiers and uses folding, case analysis, auxiliary lemmas, and a user-guided generalization to obtain a finite symbolic invariant.

The final invariant is closed modulo the NuITP obligations produced during the development. These obligations are part of the verification argument and are provided as separate proof material.

Mutual exclusion is checked negatively by intersecting the verified invariant with a symbolic error pattern containing two critical processes. The final query reports No intersection.

Run it

Extract the DM-Check archive and, from that folder, replay the whole case study with its script:

$ maude -allow-files
Maude> load examples/bakery/bakery.maude
Maude> load dm-check.maude

DM-Check> load examples/bakery/bakery.dmc

The script selects the module BAKERY-AUX, prints every command before running it, and stops at the end of the file or at the first command that cannot be parsed or executed. To follow the proof step by step, type the commands one by one at the prompt instead. See Install, step 5 for the script format.

The proof obligations reported by DM-Check are discharged with NuITP. From the same folder, in a new Maude session, run its script:

$ maude -allow-files
Maude> load examples/bakery/bakery.maude
Maude> load NuITP.maude
Maude> erew in NuITP : init .

NuITP> load examples/bakery/bakery.nuitp