This command is part of the experimental refinement editor.
The alternation command refines a specification statement to a non-deterministic alternation statement. It applies the following inference rule of the refinement calculus.
![]() ![]() |
where G1 ... Gn are guard predicates. The first sub-goal ensures that the guards cover all cases.
The code that is implicitly generated by this refinement rule is the following non-deterministic alternation of guarded specification statements.
if G1 ![]() ![]() ![]() |
[] ... |
[] Gn ![]() ![]() ![]() |
fi |
The alternation command is applicable
when any specification statement F[P,I,Q] in a goal is inspected.
Each guard in the sequence G1 ... Gn is entered into one of a sequence of dialogue boxes using the syntax of a Z predicate. The sequence is ended by giving an empty response. The default response is nothing. Alternatively, if some suitable predicates are displayed in the same window, they can have been selected first (crossed). Additional guards can then be entered in dialogue boxes. The guards are typechecked in the environment of the inspected specification statement. An error in any dialogue box aborts the entire alternation command.
There must be at least one guard.
"alternation" "G1" ... "Gn" p
This example applies the alternation command to specification statement p using the guards G1 ... Gn.
A tactic that applies the alternation command must be executed by play tactic; it is not applicable under apply tactic as the resulting code would not be accessible to the code command.