Skip to content

CIF to CIF transformation may produce invalid models for algebraic parameters with int type instantiated with constant value

Consider the model:

group def G(alg int nr):
    alg bool x =
        switch nr:
            case 0 : true
            case 1 : false
            else     true
        end;
end

g0: G(0);
g1: G(1);

Eliminating the definition leads to:

group g0:
  alg bool x = switch nr: case 0: true case 1: false else true end;
  alg int nr = 0;
end
group g1:
  alg bool x = switch nr: case 0: true case 1: false else true end;
  alg int nr = 1;
end

Which leads to the following syntax error for case 1 where nr = 0 (and likewise for case 0 where nr = 1):

The switch "case" is of type "int[1..1]", which is not compatible of type "int[0..0]" of the control value of the switch.

The model simulates without any problem.

Edited by Dennis Hendriks