
์ด ํด์ ์ํํธ์จ์ด ํ
์คํ
์ด๋ก ์์
์์ ์ฒ์ ์ ํ๊ฒ ๋์๊ณ , model-based testing์ ์๋ํํด์ฃผ๋ ๋๊ตฌ์ด๋ค. ๊ณผ์ ๋ฅผ ์ํด ๊ฐ๋จํ๊ฒ ๋ฐฐ์ ๋๋ฐ ํ
์คํธ ์ผ์ด์ค๋ฅผ ํ์ฉํด์ผ ํ๋ ๊ฒฝ์ฐ ์ค์ฉ์ ์ผ ๊ฒ ๊ฐ์ ์ ๋ฆฌํด๋๋ค.
NuSMV๋ Binary Decision Diagram(BDD)๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ ์ต์ด์ ๋ชจ๋ธ ๊ฒ์ฌ ๋๊ตฌ์ธ SMV๋ฅผ ๋ค์ ๊ตฌํ, ํ์ฅํ ๊ฒ์ด๋ค. ๋ชจ๋ธ ํ์ธ์ ์ํ ๊ฐ๋ฐฉํ ์ํคํ ์ฒ๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ CTL๊ณผ LTL ํํ์์ ์ง์ํ๋ค. ๊ฐ๋จํ ๋งํด Model-based testing tool์ด๋ผ๊ณ ํ ์ ์๋ค.
LTL์ Linear time Temporal Logic์ ์ฝ์๋ก, ์์ ๋ ผ๋ฆฌ๋ฅผ ์๋ฏธํ๋ค. True/False์ ์๊ฐ์ ๋์ ํ ๊ฐ๋ ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ์ฝ๋ค.
CTL์ Computational Tree Logic์ ์ฝ์๋ก, ์์ ๋ ผ๋ฆฌ์ ํ ์ข ๋ฅ์ด๋ค. CTL์์๋ ์๊ฐ์ ํ๋ฆ์ ํธ๋ฆฌ ๊ตฌ์กฐ๋ก ํํํ๋ค. LTL์์ A์ E๊ฐ ์ถ๊ฐ๋ ๊ตฌ๋ฌธ์ ๊ฐ์ง๋ค.
G (p->q) // G : ์๊ฐ์ ํ๋ฆ๊ณผ ๋ฌด๊ดํ๊ฒ ํญ์ ์ฐธ์ด๋ค
F (p&&q) // F : ์ธ์ ๊ฐ๋ ๊ทธ๋ ๋ค
p U q // U : p๊ฐ true์ด๋ค until q๊ฐ true๊ฐ ๋ ๋๊น์ง
X p // X : next step์์๋ ๊ทธ๋ ๋ค
AG (p->q) // A : ๋ชจ๋ possible execution
AF (p&&q)
A (p U q)
AX p
---
EG (p->q) // E : exist, ์กด์ฌํ๋ค
EF (p&&q)
E (p U q)
EX p

EF p์ ๊ฒฝ์ฐ (1), (2), (3) ๋ชจ๋ true์ด๋ค. ์ธ์ ๊ฐ p๊ฐ ๋๋ ๊ฒฝ๋ก๊ฐ ์กด์ฌํ๊ธฐ ๋๋ฌธ์ด๋ค.
๋ฐ๋ฉด AF p๋ (1)์์ false, (2), (3)์์๋ true์ด๋ค. (1)์์๋ ์คํ ๊ฒฝ๋ก ์ค P๋ฅผ ๊ฑฐ์น์ง ์๋ ๊ฒฝ๋ก๊ฐ ์๊ธฐ ๋๋ฌธ์ด๋ค. (2)์ (3)์์๋ initial state๊ฐ P์ด๊ธฐ ๋๋ฌธ์ ์ด๋ค ์คํ ๊ฒฝ๋ก์ด๋ ๋ฌด์กฐ๊ฑด P๋ฅผ ๊ฑฐ์น๋ค.

์์ ๊ทธ๋ฆผ์์ EF p = { A, B, C }์ด๋ค. ๊ทธ ๊ณผ์ ์ ๊ณ์ฐํด๋ณด๋ฉด ์๋์ ๊ฐ๋ค.
Calculate process : compute ฯ^n[y] such that
ฯ^n[y] = ฯ^(n+1)[y], where ฯ[y] = p โจ EX y
ฯ[false] = p โจ EX false = p -> { B } : ํ ๋ฒ์ ๋๋ฌ ๊ฐ๋ฅํ P๊ฐ true๊ฐ ๋๋ ์ง์ ฯ^2[false] = p โจ EX p -> { B, A } : ๋ ๋ฒ๋ง์ ๋๋ฌ ๊ฐ๋ฅํ P๊ฐ true๊ฐ ๋๋ ์ง์ ฯ^3[false] = p โจ EX (p V EX p) -> { B, A, C } : ์ธ ๋ฒ๋ง์ ๋๋ฌ ๊ฐ๋ฅํ P๊ฐ true๊ฐ ๋๋ ์ง์ 
์์ ๊ทธ๋ฆผ์์ EG p = { A }์ด๋ค. ๊ทธ ๊ณผ์ ์ ๊ณ์ฐํด๋ณด๋ฉด ์๋์ ๊ฐ๋ค.
Calculate process : compute ฯ^n[y] such that
ฯ^n[y] = ฯ^(n+1)[y], where ฯ[y] = p โง EX y
ฯ[true] = p โง EX true = p -> { A, B, C } : 0๋ฒ next๊น์ง P = true์ธ ์ง์ ฯ^2[true] = p โง EX p -> { A, B } : 1๋ฒ next๊น์ง P = true์ธ ์ง์ ฯ^3[true] = p โง EX (p โง EX p) -> { A } : 2๋ฒ next๊น์ง P = true์ธ ์ง์ NuSMV download link(https://nusmv.fbk.eu/downloads.html)์ ์ ์ํ๋ค.
Version 2.6.0 Without ZCHAFF ํ
์ด๋ธ์์ NuSMV-2.6.0-macosx64.tar.gz๋ฅผ ๋ค์ด๋ก๋ํ๋ค.

์ํ๋ ํด๋๋ก ์ฎ๊ธด ํ ์์ถ์ ํด์ ํด NuSMV-2.6.0-Darwin ํด๋๊ฐ ์์ฑ๋๋ ๊ฒ์ ํ์ธํ๋ค.
ํด๋น ํด๋์ ์ ๊ทผํด NuSMV/bin/NuSMV ํ์ผ์ด ์๋ ๊ฒ์ ํ์ธํ๋ค.
ํฐ๋ฏธ๋์ ์ด๊ณ NuSMV๋ฅผ ์คํํ๋ค. NuSMV๊ฐ ์๋ ํด๋์์ NuSMV ๋ช
๋ น์ด๋ก ์คํํ๋ฉด ๋๋ค.
ํฐ๋ฏธ๋์์ NuSMV ํ์ผ์ /usr/local/bin ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํด ์คํํ๋ค. sudo mv {NuSMV path}/NuSMV-2.6.0-Darwin/bin/NuSMV /usr/local/bin ๋ช
๋ น์ด๋ฅผ ์คํํ๋ฉด ์ด๋ํ ์ ์๋ค.
/usr/local/bin ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํด NuSMV๋ฅผ ์คํํ๋ค. ์ ์์ ์ผ๋ก ๋์ํ๋ฉด ์ ์ค์น๋ ๊ฒ์ด๋ค.
NuSMV๋ model checking ๊ฒฐ๊ณผ๊ฐ false์ผ ๊ฒฝ์ฐ counter example์ ์ถ์ถํด์ค๋ค. ์ด๋ฅผ ํ์ฉํด ์ผ๋ถ๋ฌ ์ํ๋ ๊ฒฐ๊ณผ(ํ
์คํธ ์ผ์ด์ค)๋ฅผ counter example๋ก ๊ฐ์ง๋ ๊ตฌ๋ฌธ์ ์
๋ ฅํด test case๋ฅผ ์์ฑํ ์ ์๋ค.
G (!state = S)G (state = N1 -> !X state = T1)์๋๋ ์ด์ฝ๋ฆฟ์ ํ๋งคํ๋ ์ํ๊ธฐ๋ฅผ model๋ก ์์ฑํ vendingmachine.smv ํ์ผ์ด๋ค.
MODULE main
VAR
state: {Initial, Ready, Inserting, Enabled, Emitting, Returning, Final};
amount: 0..1500;
coin : {100, 500};
event: {NONE, On, Off, Insert, Choose, Complete};
time : 0..11;
DEFINE
COST:= 500;
ASSIGN
init(amount):= 0;
init(time):=0;
init(state):= Initial;
init(event):= NONE;
next(state):= case
state = Initial & event = On : Ready;
state = Ready & event = Insert : Inserting;
state = Ready & event = Off : Final;
state = Inserting & amount < 500 & time < 10 : Inserting;
state = Inserting & amount >= 500 : Enabled;
state = Inserting & amount < 500 & time >= 10 : Returning;
state = Enabled & event = Choose & time < 10 : Emitting;
state = Enabled & time >=10 : Returning;
state = Emitting & event = Complete & amount >0 : Returning;
state = Emitting & amount = 0 : Ready;
state = Returning & amount =0 : Ready;
TRUE : state;
esac;
next(amount):= case
amount + coin > 1500 : amount;
state = Initial & event = On : 0;
state = Enabled & event = Choose & time < 10 & amount -COST >=0 : amount - COST;
state = Ready & event = Insert : amount+coin ;
state = Inserting & event =Insert & time < 10 : amount+coin;
state = Returning & event = Complete : 0;
TRUE : amount;
esac;
next(time):= case
time +1 > 10 : time;
state = Initial & event = On : 0;
state = Ready & event = Insert : 0;
state = Inserting & event = Insert & time < 10 : 0;
state = Inserting & time < 10 : time +1;
state = Inserting & amount >= 500 : 0;
state = Enabled & event = Choose & time < 10 : 0;
state = Enabled & time < 10 : time+1;
state = Returning & event = Complete : 0;
TRUE : time;
esac;
LTLSPEC G(state != Inserting)
LTLSPEC G(amount < 500)
LTLSPEC G(state != Enabled)
LTLSPEC G(state != Emitting)
LTLSPEC G(state != Returning)
LTLSPEC G(state = Inserting -> X (state = Enabled))
LTLSPEC G(amount > 500 -> F (state = Enabled))
LTLSPEC G(state = Enabled -> F (state = Ready))
LTLSPEC G(state = Ready -> amount = 0)
$ NuSMV -int // interactive mode - ๋ช
๋ น์ด ์ฐฝ ์ด๊ธฐ
NuSMV> read_model -i {filename} // load model
NuSMV> go // execute
NuSMV> show_property // LTLSPEC ๋ฑ์ property list
NuSMV> check_ltlspec -n {spec number} // ์ ํํ spec์ ์คํ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค
NuSMV> quit
NuSMV> reset
์ด๋ฅผ ์คํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ด ํ์๋๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

model checking tool์ ํ์ฉํ๋ฉด model-based testing์ ์๋์ผ๋ก ๋ง๋ค์ด๋ผ ์ ์๋ค. ๋ณต์กํ ๋ชจ๋ธ์ ๊ฒฝ์ฐ ํ๋ค๊ฒ ์ง๋ง, ํ์คํ ๊ฒ์ฆ์ด ํ์ํ ๊ฒฝ์ฐ์๋ ์ค๋ฌด์์ ์ ์ฉํ ์ ์์ ๊ฒ์ผ๋ก ๋ณด์ธ๋ค.
Reference : LTL and CTL