People hear "formal methods" and picture a year of proofs. Here is a tiny spec that finds the classic lost update: two processes each do counter = counter + 1 as a read followed by a separate write.
---- MODULE LostUpdate ----
EXTENDS Naturals
VARIABLES counter, tmp, pc
Procs == {1, 2}
Init == /\ counter = 0
/\ tmp = [p \in Procs |-> 0]
/\ pc = [p \in Procs |-> "read"]
Read(p) == /\ pc[p] = "read"
/\ tmp' = [tmp EXCEPT ![p] = counter]
/\ pc' = [pc EXCEPT ![p] = "write"]
/\ UNCHANGED counter
Write(p) == /\ pc[p] = "write"
/\ counter' = tmp[p] + 1
/\ pc' = [pc EXCEPT ![p] = "done"]
/\ UNCHANGED tmp
Next == \E p \in Procs : Read(p) \/ Write(p)
Spec == Init /\ [][Next]_<<counter, tmp, pc>>
Correct == (\A p \in Procs : pc[p] = "done") => counter = 2
====
Tell the model checker to check Correct as an invariant (and turn off the deadlock check, since the system ends when everyone is "done"). It reports a counterexample trace in a second:
- P1 reads 0.
- P2 reads 0.
- P1 writes 1.
- P2 writes 1. Both done,
counter = 1.
The trace is the bug report. Make Read and Write one atomic step (or add a lock variable), and the invariant holds over every interleaving, not just the ones your tests happened to hit.
The failure model here: processes never crash, steps interleave arbitrarily. That is small, and it is already enough to catch a bug that code review misses.