This frees the programmer from having to make unnecessary choices and is an aid in the formal development of programs.
For example, execution of the statement x, y:= y, x is done by first evaluating the righthand side values and then storing them in the lefthand variables.
Thus, if all guards are initially false, the repetition terminates immediately, without executing an iteration.
This repetition ends when a = b, in which case a and b hold the greatest common divisor of A and B. Dijkstra sees in this algorithm a way of synchronizing two infinite cycles a := a - b and b := b - a in such a way that a≥0 and b≥0 remains true.
This repetition ends when b = 0, in which case the variables hold the solution to Bézout's identity: xA + yB = gcd(A,B) .
Generalizing the observational congruence of Guarded Commands into a lattice has led to Refinement Calculus.
Depending on the model one is willing to live with for the electrical circuit elements, additional restrictions on the guarded commands may be necessary for a guarded-command description to be entirely satisfactory.
Common restrictions include stability, non-interference, and absence of self-invalidating commands.
[3] Guarded commands are used within the Promela programming language, which is used by the SPIN model checker.
SPIN verifies correct operation of concurrent software applications.