var b0,b1,turn:bool, g:uint[3], x,y:bool; initial not b0 and not b1 and g==uint[3]0 and not x and not y; proc acquire(tid:bool) returns () begin if not tid then b0 = true; turn = tid; assume (b1==false or turn==not tid); else b1 = true; turn = tid; assume (b0==false or turn==not tid); endif; end proc release(tid:bool) returns () begin if not tid then b0 = false; else b1 = false; endif; end proc foo(tid:bool,q:bool) returns () begin if not q then x=true; y=true; foo(tid,q); else acquire(tid); g = g + uint[3]1; release(tid); endif; end proc main(tid:bool) returns () var q:bool; begin q = random; foo(tid,q); acquire(tid); if g==uint[3]0 then fail; endif; release(tid); end thread T0: var tid:bool; begin tid = false; main(tid); end thread T1: var tid:bool; begin tid = true; main(tid); end