SlideShare a Scribd company logo
1 of 25
Download to read offline
1
1
LTSAからSPINへの接続: Mine Pumpの詳細設計
モデル検査ツールを利用した開発プロセスの構築-2
藤倉 俊幸
第28回CSP研究会
2021-11-27
2
Agenda
前回(第27回CSP研究会)の続き
サンプルのMine Pumpの設計を進めた結果を報告
https://www.slideshare.net/tfujikura/ss-250537648
1. はじめに
– SPINとLTSAの比較
2. 開発プロセスのアウトライン
3. Mine Pump問題の続き
– コンポーネント分割
– SPINへの変換
4. まとめ
資料
https://static.aminer.org/pdf/PDF/000/306/006/analysis_and_verification_of_real_time_systems.pdf
Mathai Joseph, Real-Time Systems: Specification, Verification and Analysis,
2001, Prentice Hall
https://www.semanticscholar.org/paper/Real-time-systems-specification%2C-verification-and-
Joseph/d61e447a7f05d411cf55d47d145ab0a1b72cf648
3
はじめに
• モデル検査ツールには,それぞれの動作原理や前提条件があるので,何を目的として何をや
っているのか常に注意が必要.
• SPINはC言語ライクなモデリングができるので使いやすいが,上流には向いてない.
– LTLから生成するオートマタは検査に特化していて要求分析に向かない.
– モデルは手書きスタートなので,正しいかどうかが問題になる.
• 仕様検証なのか,モデルのデバッグなのか混沌としてくる.
– 良い所としては外部と内部を明確に分けるモデルを書ける.
• SPINの実行とは,実行可能な文をランダムに選んでそれを実行すること.条件文は実行可能
では無い.
– 実行可能な文が無いと終了する.あるいは,進まない.LTSAは勝手に動く.
– SPINは勝手に動かないので相方として外部環境が必要になる.
• LTSAは抽象度の高いところからモデリングできるが,詳細化には向いてない.
– 動作モデルをLTLから自動生成出来るので,手書きスタートにはにはならない.assert文からモデ
ルを作れる.
– 相方が無くても勝手に全パターンを尽くすことができる.
4
開発プロセスに組み込んだ場合のSPINとLTSAの違い
SPINの場合
SPINの場合
LTSAの場合
LTSAの場合
要求1,2,3,...
assert文1,2,3,...
モデル
動作仕様
モデル
動作仕様
要求1,2,3,...
assert文1,2,3,... モデル検査
5
never { /* !(![](p -> q)) */
accept_init:
T0_init:
do
:: (((! ((p))) || ((q)))) -> goto T0_init
od;
}
□(P ⇒ Q)から生成されるオートマタの比較
• LTSAは,原子命題の同値類で状態を生成してそれらの間の遷移関係で状態マシンを生成する.
• SPINは,原子命題まで分解しない.
• なので,SPINをLTLから動作モデルを生成する使い方は出来ない.
fluent P = <p,xp> initially 0
fluent Q = <q,xq> initially 0
assert S0 = [](P -> Q)
constraint S0 = S0
7
SPINの場合
SPINの場合 LTSAの場合
LTSAの場合
(p⇒q)を繰り返す!
!P∧!Q
!P∧!Q
!P∧Q
!P∧Q
P∧Q
P∧Q P∧!Q
P∧!Q
6
2. 開発プロセスのアウトライン
• LTSAでアーキテクチャ導出まで
• LTSAモデルのSPIN変換
• 環境モデルのSPINモデル生成
• SPINでコンポーネント通信から
• SPINで最後までいけるか?
– ある特定のアプリでは可能かも知れない.
– 組込全般は無理
SPINの利用
SPINの利用
LTSAの利用
LTSAの利用
モデル
動作仕様
要求1,2,3,...
assert文1,2,3,...
コンポーネント分割
コンポーネント仕様1,2,3,...
実装
実装にたどり着くには,実装における
並列・並行動作やイベント共有方法に
ついて正確に表現(モデル化)できる検
査ツールが必要
実装にたどり着くには,実装における
並列・並行動作やイベント共有方法に
ついて正確に表現(モデル化)できる検
査ツールが必要
変数や通信路を使える.
7
LTSAとSPINの動作の違い
• LTSAの動作
– 複数のプロセスが共通の動作をもつとき,これらの動作は共有されているという.
– 共有動作によってプロセスの相互作用はモデル化される.共有化されていない動作は任意にインター
リーブできるが,共有動作はそれを共有するすべてのプロセスによって同時に実行されなければなら
ない.
MAKER = (make->ready->MAKER).
USER = (ready->use->USER).
||MAKER_USER = (MAKER || USER).
MAKER が ready の時, USER と同期する.
MAKER USER
MAKER_USER
8
LTSA動作モデルの移植
• SPINでは環境側を作らないと状態マシンが動かない.
– 実行可能な文をランダムに選んで網羅的に実行することはできるが,入力が無いと実行可能にな
らない.
– LTSAのアニメーション時のAnimatorにあたるプロセスを環境側として作る必要がある.
イベントセレクタ
コンポーネントの状態によって実行可能
なイベントをセレクトする
ちなみにSPINでは合成した状態図を見る
ことはできない.
P = (a -> b -> c -> P).
Q = (x -> b -> Q).
9
イベントセレクタの実装
• 各コンポーネントの各状態で実行可能(受理可能)なイベントを選択する.
– 状態変数が必要になる.
– model側とselecctor側が同期を取って動く必要がある.
ただし,(P||Q)が分からないとSelectorは作れない.
ただし,(P||Q)が分からないとSelectorは作れない.
active proctype Selector() {
do
:: p == false && q == false ->
if
:: (pST == 0) -> ev = a
:: (pST == 1 && qST == 1) -> ev = b
:: (pST == 2) -> ev = c
:: (qST == 0) -> ev = x
fi;
p = true
q = true
od
}
active proctype Q() {
do
:: q ->
if
:: qST == 0 ->
if
:: (ev == x) -> qST = 1
:: else -> skip
fi;
:: qST == 1 ->
if
:: (ev == b) -> qST = 0
:: else -> skip
fi;
:: else -> skip
fi
q = false
od
}
q:同期変数
qST:同期変数
状態型
状態型
10
SPIN状態図
P = (a -> b -> c -> P).
Q = (x -> b -> Q).
イベントセレクタ
P Q
11
2. Mine Pump
• 鉱山に浸透した水はサンプに集められ、鉱山から汲み出
される.
• 水位センサーDとEは、水がそれぞれ高レベルと低レベ
ルを超えたことを検出する.ポンプコントローラーは、
水が高水位に達するとポンプをオンにし、低水位を下回
るとポンプをオフにする.ポンプの故障により水を汲み
出すことができない場合は、1時間以内に鉱山から避難
させる必要がある.
• 鉱山ポンプには、一酸化炭素、メタン、および気流レベ
ルを監視するためのセンサー(A、B、C)がある.こ
れらのレベルのいずれかが危険な状態になると,1時間
以内に避難できるように、警報を発し、1秒以内にオペ
レーターに通知する.
• 爆発のリスクを回避するために、ポンプはメタンレベル
が臨界レベルを下回っている場合にのみ操作する.
(鉱山の坑底の)水だめ
Overview (状況,背景説明)
12
システム要求
Overview (状況,背景説明)
Safety Req.
Operational Req.
Problem (Subject)(目標,ゴール)
システム要求(自然言語記述要求)
• メタンレベルが臨界値の場合は、ポンプを操作しない.
• ポンプが故障してから1時間以内に鉱山から避難させる.
• メタンレベル、一酸化炭素レベル、または気流レベル
が重要な場合は、アラームを発生させる.
鉱山は通常1日3シフトで操業
されている.水位が高いため
に失われるのは1000回に1シ
フトを超えない.
安全要件に違反することなく、可能な限り鉱山が稼働していることを示
すことができる鉱山ポンプコントローラーの仕様を作成して検証する.
13
仕様の形式化
• 変数の定義
– タイプ T の変数 V
– V : T
• 関数の定義
– タイプ T1 (関数の定義域)からタイプ T2 (関数の範囲)ま
での関数 F の場合、
– F : T1 → T2
• プロパティの定義
– 論理演算子∧(and), ∨(or), ⇒(implies) , ⇔(iff), ∀(for all) を使用し
た単純な述語計算式
Safety Req.
Operational Req.
システム要求(自然言語記述要求)
S1 : Water level
S3 : Assumptions
S4 : Pump controller
S2 : Methane level
S5 : Sensor
システム仕様(形式記述要求)
S6 : Actuator
• 論理変数の抽出
• 述語計算式の時相論理式化
動作仕様(形式記述要求)
14
振る舞いの合成と分解
• 振る舞いの合成と分解
– 要求から生成されたシステム全体の振る舞いモデ
ルをコンポーネントに分解しコンポーネント毎の
振る舞いモデルとコンポーネント間の関係(インタ
フェース)を導出する.
||SumpContr = (S4a||S4b).
||Pump0 = SumpContr @{on, off}.
||PumpContr0 = SumpContr ¥{on, off}.
setOn: onに対応する通信
setoff: offに対応する通信
S4制御とは独立なpumpの動き
15
インターフェイスの設計
• コンポーネントに分解したことにより,再定義が必要なアクションをtauが表している.
これに正しいアクションを割り当てる必要がある.
– PumpContr0はPump0にseton/setoffを送る.
– Pump0はon/off状態をフィードバックする.
seton/setoff
on/off
tauの部分をseton/setoffで置き換える.
tauの部分をseton/setoffで置き換える.または,フィードバックを受
けるのであれば,(seton→on)/(setoff→off)で置き換える.
16
インタフェースの検証
• 検証によりdeadlockが発生す
ることが分かった.
• 合成した段階で,出口のない状
態の存在が分かった.(状態
10)
• どのようなシーケンスでデッド
ロックするか調べるためにモデ
ル検査を実施した.
onの状態でメタン濃度が上がったのでsetoffを送信した.
offになる前にメタン濃度が下がったのでsetonを送信しようとしたが送信できない.offのフィードバッ
ク待ちになっている.
off待ち
17
Deadlock修正版
on待ち,off待ちの時も次のコマ
ンドを受けられるように修正した.
18
動作モデル対応
要求検証
設計仕様
システムテスト仕様
19
Mine pumpの環境モデル
• メタンセンサーの場合
fluent High = <up, down> initially 0
assert HighState = [](high -> High)
assert LowState = [](low -> ! High)
constraint HighState = HighState
constraint LowState = LowState
assert Alternate = []((up -> X !up)&&(down -> X !down))
constraint Alternate = Alternate
状態とイベントメッセージの定義
状態メッセージの定義
同じイベントが連続しない条件
メタン濃度
up down
High状態
Low状態
20
環境モデルのSPINによる実装
•
active proctype Env() {
do
:: timeout;
if
:: (evST == 0) ->
if
:: ev = low;
:: ev = up; evST = 1;
fi
:: (evST == 1) ->
if
:: ev = high
:: ev = down; evST = 0;
fi
fi;
od
}
byte evST;
mtype = {up, down, low, high, none}
mtype ev;
active proctype Ctrl() {
do
::if
:: (ev == high) -> printf("high ¥n");
:: (ev == low) -> printf("low ¥n");;
fi
od
}
init {
atomic {
ev = none;
evST = 0;
}
}
コントローラ
コントローラ
プラント
プラント
21
Mine pumpの環境モデル
• 水位計の振る舞いをモデル化する.
Low
High
Empty
E D state メッセージ 条件 状態定義 状態メッセージ定義
1 0 0 Empty wempty ! E && ! D assert EmptyWater = (! E && ! D) assert EmptyState = [](wempty -> EmptyWater)
2 0 1 error er E && ! D assert SensorError = (!E && D) assert ErrorState = [](wer -> SensorError)
3 1 0 Low wlow E && D assert LowWater = (E && ! D) assert LowState = [](wlow -> LowWater)
4 1 1 High whigh !E && D assert HighWater = (E && D) assert HighState = [](whigh -> HighWater)
センサ イベント メッセージ fluent定義
1 E 0 -> 1 e1 fluent E = <e1, e0> initially 0
2 E 1 -> 0 e0
3 D 0 -> 1 d1 fluent D = <d1, d0> initially 0
4 D 1 -> 0 d0
22
Water 環境モデル
// Water sensor
fluent E = <e1, e0> initially 0
fluent D = <d1, d0> initially 0
assert EmptyWater = (! E && ! D)
assert LowWater = (E && ! D)
assert HighWater = (E && D)
assert SensorError = (!E && D)
assert LowState = [](wlow -> LowWater)
assert EmptyState = [](wempty -> EmptyWater)
assert HighState = [](whigh -> HighWater)
assert ErrorState = [](wer -> SensorError)
constraint LowState = LowState
constraint EmptyState = EmptyState
constraint HighState = HighState
constraint ErrorState = ErrorState
||WaterSensor = (LowState||EmptyState||HighState||ErrorState).
23
まとめ
• LTSAでアーキテクチャ設計までやって,SPINに引き継ぐ方法について検討した.
• SPINを開発プロセスに組み込んで使うのは難しいかも知れない.特定の問題をローカルに
とくのに向いている.
– 一般的なモデル変換が難しい
• LTSAの後工程に使うにはFDRかNuSMVが良いと思う.
• モデルの動作セマンティックの自由度が一番高いのがnuSMV,または上位互換のnuXmvで
はないかと思う.
24
Thank you for listening!
25
© 2021, Laboratory Design
すべての権利は留保されています。書面による許可なしに、本出版物の全部または一部を複製することを禁じます。
All rights reserved. Written permission is required for reproduction of all or parts of this publication.
The source must be stated in any such reproduction.
This publication and the contents hereof are subject to change without notice.
Brand names or product names are trademarks or registered trademarks of their respective companies
or organizations.
https://embresearch.com/

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Ltsaからspinへの接続 mine pumpの詳細設計