Peterson’s algorithm
Lean models and proofs for a classic mutual exclusion algorithm.
Two processes want to use the same critical section. Each can read and write shared variables, but their steps may be interleaved. Peterson’s algorithm coordinates access using two flags and a turn variable.