Professional Documents
Culture Documents
Ishii
Ishii
物理情報系のSMTモデル検査
SMT-based Model Checking of
Cyber-Physical Systems
2023年10月,October, 2023
石井 大輔 / Daisuke ISHII
次世代デジタル社会基盤研究領域,Next-gen digital infrastructure area
dsksh@jaist.ac.jp, https://www.dsksh.com
概要 / Summary
• Topics
- 物理情報系 / Cyber-physical systems (CPS)
- モデルベース開発 / Model-based development
- モデル検査 / Model checking
- etc.
• Goal: Get an idea of how to improve the dependability
of CPS
SMT
Encoding solving Decoding
Logic Proof of
CPS model Satis ability
formula dependability
2
fi
物理情報系とモデルベース開発
Cyber-Physical Systems and Model-based
Development
物理情報系 / Cyber-physical systems (CPS)
• Computer systems that is tightly integrated with physical
environment
- Input: sensors; Output: actuators
- Hybrid system of discrete and continuous behaviors
- Example: automobiles, airplanes, robots, houses, medical
devices, power plants, etc.
• Inter-disciplinary area
- Programming languages, software engineering, numerical
simulation, control theory, optimization, etc. Image courtesy of NSF. 4
物理情報系 / Cyber-physical systems (CPS)
• Original denition: Integration of computation with
physical processes [H. Gill@NSF 2006]
- Composed of heterogeneous, potentially distributed,
components and systems, CPS bridges the digital and physical
worlds [NIST, 2017]
- A keyword of a science and technology policy in the U.S.
✴ Cf. Industrie 4.0 [Germany 2011]
✴ Cf. Society 5.0 [Japan 2016]
5
fi
物理情報系 / Cyber-physical systems (CPS)
• Typical structure:
Computation
Sensing Data
Action / Actuation
Physical Component
E. Lee and S. Seshia: Introduction to Embedded Systems (2nd Ed.), MIT Press, 2017. 6
Example CPS
• (Autonomous, electric) computer-controlled cars
• Smart watches with biosensors
7
Example CPS
• Cyber-physical gaming
• ROS-based robots
(c) Nintendo
(c) Niryo 8
Development process of CPS
• V model with early model-based V&V (veri cation and validation)
Requirement
Model-based Model V&V System V&V
analysis
design
Conceptual Testing w/ System
modeling simulation integration
Simulation w/
Detailed modeling
hardware
Hardware
implementation
fi
Model-based design
• Development approach that exploits a "model" of the
target system
- Create a virtual product on a computer and simulate/analyze its
behaviors
- Parameter calibration, performance evaluation, V&V, etc.
- Models may be iteratively re ned into real products
10
fi
fi
Modeling CPS
• Describe two components x'(t) = u(t) cos θ(t)
https://automaticaddison.com/how-to-make-a-
line-following-robot-using-raspberry-pi/
[Lee&Seshia, 2017]
12
Example CPS model (line tracer)
• Physical component (plant) Output signal x'(t) = u(t) cos θ(t)
- Di erential equation y'(t) = u(t) sin θ(t)
θ'(t) = w(t)
Input signal
13
ff
Example CPS model (line tracer)
• Model described with Simulink/State ow
14
fl
Example CPS model (line tracer)
model Vehicle(eps1, eps2) =
initially
• Model described m = "straight",
x = 0, x' = 0, y = 0, y' = 0, th = pi/2, th' = 0,
with Acumen u = 0, w = 0, e = 0
always
[Taha+ 2015] x' = u*cos(th), y' = u*sin(th), th' = w,
match m with
[ "stop" -> u = 0, w = 0, m+ = "straight"
| "straight" -> u = 10, w = 0,
if e > eps2 then m+ = "right"
elseif e < -eps2 then m+ = "left" noelse
| "right" -> u = 10, w = -pi,
if abs(e) < eps1 then m+ = "straight"
elseif e < -eps2 then m+ = "left" noelse
| "left" -> u = 10, w = pi,
if abs(e) < eps1 then m+ = "straight"
elseif e > eps2 then m+ = "right" noelse
],
... 15
Example CPS
• Example name
- P (physical component)
- D (sensing data from the physical component)
- C (what to compute w/ the cyber component)
- A (actuation data from the cyber component)
• Automobile
- P: motor, steering system, tires
- D: surrounding image, past trajectory of the vehicle
- C: safe driving control
- A: driving input (steering, acceleration and braking)
16
Example CPS
• Robot arm
- P: robot arm hardware
- D: current joint angles, end-e ector position
- C: smart control (e.g. model-predictive control)
- A: input voltage to the joint motors
• Smartwatch
- P: human user
- D: body temperature, heart rate, blood pressure
- C: human state estimation, anomaly detection
- A: sounds and images
17
ff
Benefits of the model-based
approach
• Simulation
- Execute a model on computers 表2 サーモスタットの統計的モデル検査結果. 124 CHAPTER 4. TAYLOR MODEL FLOWPIPES FOR HYBRID
n 59 167 930 96 50 `1 `2
x 2 [0.9, 1.1]
• Testing
Sat 27 81 428 36 24 y 2 [ 1.1, 0.9]
ẋ = y ẋ = y
実行時間 (s) 477 1150 6070 700 390 ẏ = x2 ẏ = x3
採用した仮説 H0 H0 H1 H1 H1 x y 3 2 y
• Model checking
データやモニタリング結果が JSON ファイルとして出力され
る. フロントエンドプロセスは JSON ファイルを介してモニタ
リング結果を取得し, 集計結果について SPRT 法による仮説検 P1: req(y)
-
P2: req(y)
統計的モデル検査の結果, シミュレーション・モニタリング
exhaustively and check a property
結果を保存した JSON ファイル群が生成される. 検査結果を直
P1: CS
P2: req(y)
y: 0
P1: req(y)
P2: CS
y: 0
感的に把握できるようにするため, これらのファイルの内容を
[Chen, 2015]
rigorously 要約し, グラフ描画ライブラリ Breeze-viz を用いて可視化す
(注 9)
P1: rel(y) P1: req(y)
る機能を実装した. 本機能に可視化したい model インスタン P2: req(y) P2: rel(y)
ス識別子および変数名を与え, 無作為シミュレーションされた
y: 1
図 6 サーモスタットの検査に関する可視化
Figure 4.17: Flowpipe over-approximations (of乱数集合
y: 1
) の例.
the 2-dimensional
18
stable
横軸は k1, 縦軸は k2 の値を表す.
SMTソルバーを用いたCPSモデル検査
CPS Model Checking using SMT Solvers
Overview
• Issues in the modeling/simulation/veri cation of
cyber-physical systems (CPS)
- Autonomy and scaling (in size and complexity) of systems
- Approximations made in modeling (abstraction) and
simulation (numerical errors)
- Computational di culty in veri cation
- etc.
Requirement
Model checking System V&V
analysis
Detailed Simulation w/
modeling hardware
Hardware
implementation
21
fi
Model checking via logic encoding
• Example: veri cation of a Simulink model
in@1,sum@1,dl@1,... : real
1
1 8 Const1● ●
○
●
○ ●
○ ○
● ○
● ○
In1 ● ● ○
○ >5 ● ○
○ s
Saturate 61 1 1● ● ○ ● 1
Out1 ● ○
○ ● o
Add In1
4 ●
●
○
○
Out1
● ○
● ○
2 ● ○
●
■ ○
■ ■ Subsystem1
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
0○ ■ ■ ■ ■ i
23
I
O
n
u
1
t
1
Invariance properties
• Properties stating that "always ϕ holds" where ϕ is a
property on a state
Out < 10
- Example: "always Out < 10"
Example: "always Out ≠ 2"
8 ● ○
-
● ●
○ ○
● ●
○ ○ ● ○
● ●
○ ○ ● ○
6 ● ●
○ ○ ● ○ s
● ○ ● o
● ○
4 ●
●
○
○
● ○
2 ● ○
●
■ ○
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
0○ ■ ■ ■ ■ i
5 10 15
24
SMT solvers
• Tool for checking satis ability modulo theories
- Input: predicate logic formulas
- Based on e cient search algorithms
- E.g. Z3, https://github.com/Z3Prover/z3
- E.g. CVC5, https://cvc5.github.io/
• Example theories
- Integer/real arithmetic x = 2y + 1 ∧ ( x > y z=y/x)
- Equality and functions x, y: integer variables
- Bit vectors z: real variables
- Di erential equations Solution: Satis able
x = 3, y = 1, z = 0.333...
25
ff
ffi
fi
fi
SMT solving example
Description in the SMT-LIB format:
;; Declaration of constants.
(declare-const x Int)
(declare-const y Int)
(declare-const z Real)
x = 2y + 1 ∧ ( x > y z=y/x)
;; Assertions of constraints.
x, y: integer variables (assert (= x (+ (* 2 y) 1)))
(assert (=> (> x y) (= z (/ y x))))
z: real variables
;; Check the satisfiability.
(check-sat)
;; Additional assertion.
(assert (and (> x y) (< x 0)))
;; Check again.
(check-sat)
26
Solving process of SMT solver
-1 <= in <= 1 /\ P1 /\ P1: T
sum = in + 0.9*dl /\ P2 /\ P2: T
dl = 5.0 /\ P3 /\ P3: T
(not sum <= 0.6 \/ out = 1) /\ (not P4 \/ P5) /\ P4: F
(sum <= 0.6 \/ out = 2) /\ (P4 \/ P6) /\ P5: F
out = 2 P6 P6: T
Extraction of
Predicate logic formula SAT checking
propositional formula
9
8
-1 <= in <= 1 /\
sum = in + 0.9*dl /\
SAT 7
dl = 5.0 /\
(assignment
example)
* 6
Invariance proof or
End
a counterexample
D. Ishii,
Fig. 2. The process T. Tomita, model
of SMT-based T. Aoki, T.Q. Ngô, T.B.N. Do, H. Takai:
checking.
SMT-Based Model Checking of Industrial Simulink Models,
https://www.gaio.co.jp/products/prompt-2/ ICFEM, LNCS 13478, pp. 156-172, 2022.
28
where s ∈ D(V ), i ∈ D(V ), o ∈ D(V ), I(s ), and T (s ,s ,i ,o )
fi
Simulink encoding example
• Models can be regarded as relations on input, output, and
internal state signals
• Description of the relations in SMT-LIB
I(s0) ⟺ s0 = 0
1
1 Const1
In1 1 1 1 >5 1
Saturate Out1
Add In1 Out1
Subsystem1
Gain
(
D. Ishii et al.
o
R
e
a
l
)
)
Delay
o ≤ 10
1
Out1
• Invariant instrumentation
1
In1
1
Simulink encoding example
Subsystem1
Const2
Const1
>5
Switch
1
Out1
30
Simulink encoding example
• Encoding of execution paths
...
32
fi
properties.
(2)th 16 1 14 2 14 7 14 10 2 14 29 2
th
the
289
Z3
22 ≥ 34 2 —
1 1 —
PM A
• Comparison with
TO
TO
TO
TO
TO
TO
Error
Error
PM E
1000 SLDV
A
100
Error
Error
an o cial veri cation 10
A TO
A TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
Error
1000
Outperformed on 17 100
out of 28 properties 10
34
fi
Example master's research
• Compositional checking of models
- Issue: Scalability issue of the model checking process
- Approach: Composition of the target and module-wise processing
- Research items: 部品A ¦=(□In ) ⇒ (□Out )
A A
✴ Compositional MC method 部品B ¦= (□InB) ⇒ (□OutB)
✴ Automation of compositional MC
Compositional 部品A ¦¦ 部品B ¦¦ 外部環境 ¦= 安全性
system
SMT
Encoding solving
Logic Veri cation
CPS module Solving result
formula result
Decoding
…
…
Logic
CPS module Solving result Compositional
formula
reasoning 35
fi
Example master's research
• Test method for a robot arm
- Issue: Gap between the model and the
implementation in the robot development
✴ E.g. gap w.r.t time and poses
- Approach:
Application of the model-based testing
(MBT) method
- Research items
✴ Speci cation of the robot model
✴ Formalization of the conformance between
the robot movements
✴ Conformance checking method
36
fi
まとめ
Conclusion
まとめ / Conclusion
• 物理情報系 / Cyber-physical systems
• Model-based design of CPS
- Description of continuous and right straight
x'(t) = u(t) cos θ(t)
discrete behaviors y'(t) = u(t) sin θ(t)
- Simulation, testing, veri cation stop left
θ'(t) = w(t)
39
ff
課題 / Assignment (S101)
• 解答例 (76文字) 自動運転の電気自動車.
P:モーター,ステアリング系,タイヤ.
D:周囲の画像,車の位置・速度.
C:安全・快適な運転.
A:操舵入力,アクセル量,ブレーキ量.