モデル検査(2) プロセス代数に基づくモデリング
DESCRIPTION
表現系工学特論. モデル検査(2) プロセス代数に基づくモデリング. (model checking). (modeling in process algebra). 1.プロセス代数 2.逐次プロセスのモデリング 3 .並行プロセスのモデリング. 参考文献 Concurrency: State Models & Java Programming, J. Magee & J. Kramer, Wiley (2006). モデル検査 ( 復習 ). モデル検査器 model checker. 検査結果. モデル model (状態遷移系). OK. 反例. - PowerPoint PPT PresentationTRANSCRIPT
表現系工学特論
参考文献Concurrency: State Models & Java Programming, J. Magee & J. Kramer, Wiley (2006)
モデル検査(2)プロセス代数に基づくモデリング
1.プロセス代数
2.逐次プロセスのモデリング
3 .並行プロセスのモデリング
(model checking)
(modeling in process algebra)
モデル検査 ( 復習 )
モデル検査器model checker
モデルmodel
(状態遷移系)
モデル記述言語
•C 言語風のもの
•プロセス代数
検査結果OK反例
性質property
(安全性,活性)
性質の記述
•時相論理
The result iseither OK or a counterexample
1.プロセス代数
代数とは何か プロセス代数とは プロセス代数に基づく言語
(process algebra)
代数とは何か 要素の集合(台)およびその上での演算の
集まりからなる計算系
a
b
cde
台(universe)
c = a ○ b
例: (整数の集合,+, × )
演算子
等号
演算
(algebra)
(operator)
(operation)
(equality)
プロセス代数とは プロセスやイベント等の集合を台とし,
プロセスの合成などの演算を定義した代数
P
QR
Q = e ○ P
a e
Process
Event
演算
(process algebra)
プロセス代数に基づく言語 CSP (Communicating Sequential Processes)
by Hoare CCS (Calculus of Communicating Systems)
by Milner FSP (Finite State Processes)
by Magee & Kramer
今回の講義ではこれを紹介
2.逐次プロセスのモデリング
プロセス=アクション+状態遷移 ラベル付き遷移系と FSP によるモデリ
ング アクション接頭辞 選択 添え字付きアクション ガード付きアクション
(modeling sequential processes)
プロセス=アクション+状態遷移 状態 (state)
プログラムカウンタの値と (明示的あるいは暗黙的な)変数の値からなる
状態遷移 (state transition) 割り込み不能の原子アクション (atomic action)
により状態が遷移する プロセス (process)
1つの逐次プログラムの実行のこと. 有限状態機械(オートマトン)でモデル化され
る
(process) (action) (state transition)
(program counter)
(variable)
(finite state machine: automaton)
ラベル付き遷移系と FSP によるモデリング
ラベル付き遷移系 (Labeled Transition System) 有限状態機械を図式的に表現したシステム
FSP (Finite State Processes) ラベル付き遷移系を代数的に表現する言語
アクション接頭辞
(a-> P)
最初にアクション a を実行し,つぎにプロセス P と同じ振る舞いをするプロセス.
(action prefix)
(a -> P) is a process that initially engages in the action a and then behaves exactly as described by the process P.
スイッチの例 (1) ラベル付き遷移系
on
off
0 1ラベル付き遷移系
OFF ON
onoffonoffonoff ……….
トレース (trace) : 実行可能なアクションの列のこと
initial state
action
(Example: a binary switch)
スイッチの例 (2) FSP による記述
FSPSWITCH = OFF,OFF = (on -> ON),ON = (off-> OFF).
代入によってより簡潔な表現を得る:SWITCH = OFF,OFF = (on ->(off->OFF)).
SWITCH = (on->off->SWITCH).
on
off
0 1ラベル付き遷移系
アクション名は小文字プロセス名は大文字
OFF ON
(Simplify the expressions by substitution)
選択
(a-> P | b->Q)
最初にアクション a ,b のいずれかを実行する.そのアクションが a ならつぎにプロセス P を実行し, b ならつぎにプロセス Q を実行するプロセス.
(choice)
(a->P | b->Q) is a process which initially engages in either a or b.The subsequent behavior is described by P if the first action was a, and Q if the first action was b.
自動販売機の例
DRINKS = ( red->coffee->DRINKS | blue->tea->DRINKS ).
red
blue
coffee
tea
0 1 2
(ボタンの色で飲み物を指定)
(Example: a vending machine)
非決定的選択Process (x-> P | x -> Q) describes a process which engages in x and then behaves as either P or Q.
COIN = (toss->HEADS | toss->TAILS),HEADS= (heads->COIN),TAILS= (tails->COIN). toss
toss
heads
tails
0 1 2
(non-deterministic choice)
COIN = (toss-> heads -> COIN |toss-> tails -> COIN ).
Single slot buffer that inputs a value in the range 0 to 3 and then outputs that value:
添え字付きアクション
BUFF = (in[i:0..3]->out[i]-> BUFF).
equivalent to
or using a process parameter with default value:
BUFF = (in[0]->out[0]->BUFF |in[1]->out[1]->BUFF |in[2]->out[2]->BUFF |in[3]->out[3]->BUFF ).
BUFF(N=3) = (in[i:0..N]->out[i]-> BUFF).
(indexed actions)
iin out
BUFF
ガード付きアクション
COUNT (N=3) = COUNT[0],COUNT[i:0..N] = (when(i<N) inc->COUNT[i+1] |when(i>0) dec->COUNT[i-1] ).
inc inc
dec
inc
dec dec
0 1 2 3
(guarded actions)
(when C a-> P | b->Q)
ガード C が真のときのみアクション a が選択され得る.アクション b は,ガードがないので,常に選択され得る.
3.並行プロセスのモデリング
プロセスの並列合成 アクションのインタリーブ ラベル付き遷移系の合成 共有アクションとインタラクション
(modeling concurrent processes)
プロセスの並列合成
(P||Q)
プロセス P と Q の並行実行を表すプロセス. || は並列合成演算子.
Commutative: (P||Q) = (Q||P)Associative: (P||(Q||R)) = ((P||Q)||R)
= (P||Q||R).
(parallel composition of processes)
アクションのインタリーブ
ITCH = (scratch->STOP).CONVERSE = (think->talk->STOP).
||CONVERSE_ITCH = (ITCH || CONVERSE).
共有アクション
無し
thinktalkscratchthinkscratchtalkscratchthinktalk
インタリーブによって可能となるトレース
かゆいところをかくプロセス
会話するプロセス
並列合成されたプロセス
並列合成は|| で書き始める
プロセス間で共有されないアクションはインタリーブされる
(action interleaving)
ラベル付き遷移系の並列合成
(0,0)
(0,1)
(0,2)
(1,2)
(1,1)
(1,0)
from ITCH
2 x 3 states
ITCH
scratch
0 1CONVERSE
think talk
0 1 2
CONVERSE_ITCH
scratch
think
scratch
talk scratch
talk think
0 1 2 3 4 5
from CONVERSE
3 states2 states
P の状態 p と Q の状態 q の組(p,q) が, P||Q の状態となる
A pair (p, q) of states of processes P and Q is a state of the composed process P || Q
共有アクションとインタラクション
共有アクション (shared action) : 並列合成されたプロセスがもつ共通のアクション.
共有アクションによってプロセスのインタラクション(interaction) をモデル化.
共有アクションは,それを共有するすべてのプロセスにおいて同時に同期 (synchronized) して実行されなければならない.
(shared action and interaction)
A shared action must be executed at the same time by all processes that participate in that shared action.In other words, those executions must be synchronized.
インタラクションの例
MAKER = (make->ready->used->MAKER).USER = (ready->use->used ->USER).
||MAKER_USER = (MAKER || USER).
インタラクションは
振舞いを制約する
3 状態3 状態
3 x 3 状態 ?
4 状態make ready use
used
0 1 2 3
shared actions:ready, used
The interaction constrains the behavior.
演習問題二人のユーザーを表すプロセス USER_A , USER_B ,および共有資源を表すプロセス RESOURCE ,およびそれらを並列合成したプロセス RESOURCE_SHARE が, FSP でつぎのように定義されている.
USER_A = (a_acquire -> a_use -> a_release -> USER_A).
USER_B = (b_acquire -> b_use -> b_release -> USER_B).
RESOURCE = IDLE, IDLE = (a_acquire -> BUSY | b_acquire -> BUSY), BUSY = (a_release -> IDLE |b_release -> IDLE).
||RESOURCE_SHARE = (USER_A || USER_B || RESOURCE).
これら4つのプロセスのラベル付き遷移系をそれぞれ描画せよ.
ここから先のスライドは授業では使わない
4.FSPの意味論の概要
ラベル付き遷移系の形式的定義 FSPの意味論の枠組み アクション接頭辞 選択 並列合成
(Introduction to the semantics of FSP)
ラベル付き遷移系 (LTS) の形式的定義(1)
States : すべての状態の集合
Act L : すべてのアクションの集合.
Lは観測可能なアクションの集合(ラベル).
τ は LTSから観測できない内部アクション
(Formal definition of Labeled Transition System: LTS)
(States is the set of all the states)
(Act is the set of all the actions)
ラベル付き遷移系 (LTS) の形式的定義(2)
有限 LTSは四ツ組 , , ,P S A q である.
S States 状態の有限集合
A Act アクションの集合.
S A S 遷移関係
(現状態,アクション,次状態)
q S 初期状態
(a set of states)
(a set of actions)
(a transition relation)
(an initial state)
ラベル付き遷移系 (LTS) の形式的定義(3)
LTS , , ,P S A q は, ( , , )q a q のとき,
アクション a A により LTS , , ,P S A q に遷移.
これを aP P と書く.
q q'
P P'a
FSPの意味論の枠組み
構文領域 Exp
意味領域 Ps
lts
意味関数 :Exlts p Ps により意味を定義.
Expは FSPで記述されるプロセス表現の集合.
Psは LTSの集合.
アクション接頭辞
( ,>( ,, )) , ,S Aa E p p a pts ql a
ただし, ( ) , , ,lts S AE q ,pは新しい状態( p S ).
p q
lts(E)
a
lts(a->E)
選択
1 1 2 2
1 2
1
1 2 1
1 1 22
2
2
( )
, ,
( , , ),( , , ,
|
)
,
a E a E
aS S A A
q
l
a
a
p
p
s
p
t
q pa
ただし, , ,( ) ( 1,2),i i ii iS A qlts iE ,
pは新しい状態( 1 2p S S ).
pq2 lts(E2)a2
lts(a1->E1 | a2->E2) q1 lts(E1)a1
並列合成
1 2 1 2 1 2, , ,| ( )| ,P qQ S S A A q
ただし, 1 1 1 1, , ,P S A q , 2 2 2 2, , ,Q S A q ,
はつぎの推論規則を満たす最小の遷移関係 ( )a .
2( )|| ||
a
a
P Pa A
P Q P Q
1( )
|| ||
a
a
Q Qa A
P Q P Q
,
|| ||
a a
a
P P Q Q
P Q P Q
インタラクション
( ) ( ) || (|| )lts ltsP P ltsQ Q