我正在努力在NuSMV中創建交通燈系統實施。現在我有6個布爾值爲NS/EW紅色,黃色,綠色。但是,當我指定它們在未來狀態中總是爲真時,它會返回錯誤。如果有人在我的代碼中看到任何錯誤,我將不勝感激。謝謝。NuSMV中的交通燈
MODULE main
VAR
nsRed : boolean;
nsYellow : boolean;
nsGreen : boolean;
time : 0..60;
ewRed : boolean;
ewYellow : boolean;
ewGreen : boolean;
ASSIGN
init(nsRed) := TRUE;
init(nsYellow) := FALSE;
init(nsGreen) := FALSE;
init(ewRed) := FALSE;
init(ewYellow) := FALSE;
init(ewGreen) := TRUE;
init(time) := 60;
next(nsRed) :=
case
(nsYellow = TRUE & (ewGreen = TRUE | ewYellow = TRUE) & time = 0) : TRUE;
(nsRed = TRUE & time = 0) : FALSE;
TRUE : nsRed;
esac;
next(nsYellow) :=
case
(nsGreen = TRUE & ewRed = TRUE & time = 0) : TRUE;
(nsYellow = TRUE & time = 0) : FALSE;
TRUE : nsYellow;
esac;
next(nsGreen) :=
case
(nsRed = TRUE & ewRed = TRUE & time = 0) : TRUE;
(nsGreen = TRUE & time = 0) : FALSE;
TRUE : nsGreen;
esac;
next(ewRed) :=
case
(ewYellow = TRUE & (nsGreen = TRUE | nsYellow = TRUE) & time = 0) : TRUE;
(ewRed = TRUE & time = 0) : FALSE;
TRUE : ewRed;
esac;
next(ewYellow) :=
case
(ewGreen = TRUE & nsRed = TRUE & time = 0) : TRUE;
(ewYellow = TRUE & time = 0) : FALSE;
TRUE : ewYellow;
esac;
next(ewGreen) :=
case
(ewRed = TRUE & nsRed = TRUE & time = 0) : TRUE;
(ewGreen = TRUE & time = 0) : FALSE;
TRUE : ewGreen;
esac;
next(time) :=
case
(time > 0) : time - 1;
(time = 0 & nsRed = TRUE) : 60;
(time = 0 & nsYellow = TRUE) : 60;
(time = 0 & nsGreen = TRUE) : 3;
(time = 0 & ewRed = TRUE) : 60;
(time = 0 & ewYellow = TRUE) : 60;
(time = 0 & ewGreen = TRUE) : 3;
--(time = 0 & nsRed = TRUE & ewRed = TRUE) : 3
TRUE : time;
esac;
-- specification
SPEC AG !(nsRed = TRUE & nsYellow = TRUE)
SPEC AG !(nsGreen = TRUE & nsRed = TRUE)
SPEC AG !(nsGreen = TRUE & ewGreen = TRUE)
SPEC AG !(nsYellow = TRUE & ewYellow = TRUE)
SPEC AG !(nsRed = TRUE & ewRed = TRUE)
SPEC AG (nsRed = TRUE | nsYellow = TRUE | nsGreen = TRUE | ewRed = TRUE | ewYellow = TRUE | ewGreen = TRUE)
--LTLSPEC F nsGreen = TRUE
LTLSPEC F ewGreen = TRUE