R1052 - modelint/shlaer-mellor-metamodel GitHub Wiki

R1052 / 1:M

Switch Action selects one or many Case

Case is selected by exactly one Switch Action


The whole purpose of a Switch Action is to determine which of multiple Cases is true for a given Scalar Value. If there are no Cases, there is no need for a Switch Action.

There is no need to supply a Case for every single value that an enumerated type may specify. Let's say that you are modeling a traffic signal and you want to stop a vehicle if the light is red or yellow and do nothing if the light is green. In that case a set of Actions may be enabled only in the first two Cases as shown below:

traffic signal? {
    .yellow, .red :
        stop -> vehicle  // don't do anything in the .green case
} 

Textually, you might lump the first two cases together in the same line, but that is just a convenience. The data flow semantics will recognize two distinct Cases that just happen to enable the same set of dependent Actions.

A given Case is, by definition, part of a single Switch Action.

Formalization

Case.(Switch action, Activity, Domain) -> Switch Action.(Action, Activity, Domain)