我在NuSMV中写了两个模块,但是我收到了错误,"案例条件并非详尽无遗"此错误指向代码中的最后一个case语句。我不知道如何解决这个问题,因为我目前拥有的案例是变量所需的唯一案例。第一个模块" train"实例化两次,以便两列火车可以在一条轨道上。模块"控制器"充当控制器,接收来自两列火车的输入并防止它们同时在桥上。
以下是代码:
MODULE main
VAR
trainE : Train(controller1.signalE);
trainW : Train(controller1.signalW);
controller1 : controller(trainE.out, trainW.out);
INVARSPEC(!(trainE.mode = bridge & trainW.mode = bridge))
MODULE Train(signal)
VAR
mode: {away, wait, bridge};
out: {None, arrive, leave};
ASSIGN
init(mode) := away;
init(out) := None;
--Task A1
next(out) := case
mode = away: arrive;
mode = bridge: leave;
TRUE: None;
esac;
--Task A2
next(mode) := case
mode = away & next(out) = arrive: wait;
mode = bridge & next(out) = leave: away;
mode = wait & signal = green: bridge;
TRUE: mode;
esac;
MODULE controller(outE, outW)
VAR
signalE: {green, red};
signalW: {green, red};
west: {green, red};
east: {green, red};
nearE: boolean;
nearW: boolean;
ASSIGN
init(west):= red;
init(east):= red;
init(nearW):= FALSE;
init(nearE):= FALSE;
--Task A1
next(signalW):= west;
--Task A2
next(signalE):= east;
--Task A3
next(nearE):= case
outE = arrive: TRUE;
outE = leave: FALSE;
esac;
next(nearW):= case
outW = arrive: TRUE;
outW = leave: FALSE;
esac;
next(east):= case
next(nearE) = FALSE: red;
west = red: green;
esac;
next(west):= case
next(nearW) = FALSE: red;
east = red: green;
esac;
答案 0 :(得分:2)
您在所有case
条件中实际上都有相同的错误:
file test.smv: line 68: case conditions are not exhaustive
file test.smv: line 64: case conditions are not exhaustive
file test.smv: line 60: case conditions are not exhaustive
file test.smv: line 56: case conditions are not exhaustive
让我们考虑第56
行的错误。您写了以下案例:
next(nearE) := case
outE = arrive : TRUE;
outE = leave : FALSE;
esac;
现在,outE
是与trainE.out
相关联的输入。在模块Train
内,out
被声明为一个变量,可以包含 3个可能的值:{None, arrive, leave}
。但是,在您的代码中,仅为两个可能的nearE
的当前值指定outE
的未来值。因此, NuSMV 正确地抱怨,因为在当前状态nearE
等于{{1}时,它不知道在下一个状态下应该为outE
分配什么值}。
因此,为了解决此错误,您应该考虑在None
时想要发生什么,并将该规范添加到模型中。
如果您不希望outE = None
的值发生变化,通常的设计做法是添加捕获所有案例条件,如下所示:
nearE