c2e2: a tool for verifying stateflow models

33
C2E2: A Verification Tool For Stateflow Models Parasara Sridhar Duggirala, Sayan Mitra, Mahesh Viswanathan, Matthew Potok

Upload: others

Post on 01-Jan-2022

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: C2E2: A Tool For Verifying Stateflow Models

C2E2: A Verification Tool For Stateflow Models

Parasara Sridhar Duggirala, Sayan Mitra, Mahesh Viswanathan, Matthew Potok

Page 2: C2E2: A Tool For Verifying Stateflow Models

Pacemaker โ€“ Cardiac Cell System

2

+

Page 3: C2E2: A Tool For Verifying Stateflow Models

Pacemaker โ€“ Cardiac Cell System

3

๐‘ž0

๐‘ž2๐‘ž3โ€ฆ

stimulatingpulse

Pacemaker๐‘ž1

HA = Finite State Machine + Differential Equation

time

๐‘ข(๐‘ก) ๐‘ฅ1(๐‘ก)

time

Stimulus from pacemaker Behavior of a cardiac cell

Page 4: C2E2: A Tool For Verifying Stateflow Models

Safety Verification

Inputs: 1. Model of the system ๐ด,2. Initial States ฮ˜, and 3. Unsafe States ๐‘ˆ

Output: If the system is safe or unsafeโˆ€๐‘ฅ โˆˆ ฮ˜, ๐œ‰ ๐‘ฅ, ๐‘ก โˆ‰ ๐‘ˆ

4

๐‘ฅ1(๐‘ก)

time

Unsafe Set

Stateflow Model of Pacemaker โ€“ Cardiac Cell systemFeatures: Invariants, Guards, and Resets

SolutionReachable Set Computation

Features of the Model

Page 5: C2E2: A Tool For Verifying Stateflow Models

Contributions

Simulation based verification algorithm for Fully Hybrid Systems

Theoretical guarantees โ€“ Soundness and Relative Completeness

Tool Featuresโ€ข Stateflow Models, hyxml intermediate formatโ€ข Graphical User Interfaceโ€ข Visualizing the reachable set

5

Page 6: C2E2: A Tool For Verifying Stateflow Models

Overview

Motivation and Problem Statement

Challenges in Verification

Building Blocks and Algorithm

Soundness and Relative Completeness Guarantees

Tool Features

Annotations

Future Work

6

Page 7: C2E2: A Tool For Verifying Stateflow Models

Safety Verification

Inputs: 1. Model of the system ๐ด,2. Initial States ฮ˜, and 3. Unsafe States ๐‘ˆ

Output: If the system is safe or unsafeโˆ€๐‘ฅ โˆˆ ฮ˜, ๐œ‰ ๐‘ฅ, ๐‘ก โˆ‰ ๐‘ˆ

7

๐‘ข(๐‘ก)

time

Unsafe Set

Stateflow Model of Pacemaker โ€“ Cardiac Cell systemFeatures: Invariants, Guards, and Resets

SolutionReachable Set Computation

Page 8: C2E2: A Tool For Verifying Stateflow Models

Challenges In Reachable Set Computation

Nonlinear ODEs โ€“ do not even have a closed form solution

Switching conditions โ€“ predicates on variables (nondeterminism)

8

Our Technique: Use simulations for computing Reachable Set

๐‘ข(๐‘ก)

time

Unsafe Set

Stateflow Model of Pacemaker โ€“ Cardiac Cell systemFeatures: Invariants, Guards, and Resets

Page 9: C2E2: A Tool For Verifying Stateflow Models

9

Given start and unsafe

Compute finite cover of initial set

Simulate from the center ๐‘ฅ0 of each cover

Bloat simulation so that bloated tube contains all trajectories from the cover

Union = over-approximation of reach set

ฮ˜

๐‘ฅ0

๐‘ˆ

A Simple (Often The Only) Strategy

แˆถ๐‘ฅ = ๐‘“(๐‘ฅ)

๐ต๐œ–(๐œ‰(๐‘ฅ0, ๐‘ก))

Page 10: C2E2: A Tool For Verifying Stateflow Models

10

Given start and unsafe

Compute finite cover of initial set

Simulate from the center ๐‘ฅ0 of each cover

Bloat simulation so that bloated tube contains all trajectories from the cover

Union = over-approximation of reach set

Check intersection/containment with ๐‘ˆ

Refine

ฮ˜

๐‘ฅ0

๐‘ˆ

A Simple (Often The Only) Strategy

แˆถ๐‘ฅ = ๐‘“(๐‘ฅ)

๐ต๐œ–(๐œ‰(๐‘ฅ0, ๐‘ก))

Page 11: C2E2: A Tool For Verifying Stateflow Models

11

Given start and unsafe

Compute finite cover of initial set

Simulate from the center ๐‘ฅ0 of each cover

Bloat simulation so that bloated tube contains all trajectories from the cover

Union = over-approximation of reach set

Check intersection/containment with ๐‘ˆ

Refine

ฮ˜

๐‘ฅ0

๐‘ˆ

A Simple (Often The Only) Strategy

แˆถ๐‘ฅ = ๐‘“(๐‘ฅ)

๐ต๐œ–(๐œ‰(๐‘ฅ0, ๐‘ก))

Page 12: C2E2: A Tool For Verifying Stateflow Models

12

Given start and unsafe

Compute finite cover of initial set

Simulate from the center ๐‘ฅ0 of each cover

Bloat simulation so that bloated tube contains all trajectories from the cover

Union = over-approximation of reach set

Check intersection/containment with ๐‘ˆ

Refine

1. How do we get the simulations?

2. How much to bloat?

3. How to handle mode switches?

ฮ˜

๐‘ฅ0

๐‘ˆ

A Simple (Often The Only) Strategy

แˆถ๐‘ฅ = ๐‘“(๐‘ฅ)

๐ต๐œ–(๐œ‰(๐‘ฅ0, ๐‘ก))

Page 13: C2E2: A Tool For Verifying Stateflow Models

Building Blocks : Simulations

Simulation from ๐‘ฅ0 given as ๐œ‰(๐‘ฅ0, ๐‘ก) โ€“ no closed form!

13

๐’”๐’Š๐’Ž๐’–๐’๐’‚๐’•๐’Š๐’๐’(๐’™๐ŸŽ, ๐’‰, ๐, ๐‘ป) gives a sequence S0, โ€ฆ , ๐‘†๐‘˜:1. at any time ๐‘ก โˆˆ [๐‘–โ„Ž, ๐‘– + 1 โ„Ž], ๐œ‰ ๐‘ฅ0, ๐‘ก โˆˆ ๐‘†๐‘–2. ๐‘‘๐‘–๐‘Ž ๐‘†๐‘– โ‰ค ๐œ–

๐’—๐’‚๐’๐‘บ๐’Š๐’Ž(๐’™๐ŸŽ, ๐‘ป, ๐’‡) generates such simulations (CAPD)

Page 14: C2E2: A Tool For Verifying Stateflow Models

Building Blocks : Discrepancy Function

Discrepancy Function: capturing the continuity of ODE solutionsexecutions that start close, stay close

โŸจ๐พ, ๐›พโŸฉ is called an exponential discrepancy function of the system if for any two states ๐‘ฅ1 and ๐‘ฅ2 โˆˆ ๐‘‹, for any t |๐œ‰(๐‘ฅ1, ๐‘ก) โˆ’ ๐œ‰(๐‘ฅ2, ๐‘ก)| โ‰ค ๐พ ๐‘ฅ1 โˆ’ ๐‘ฅ2 ๐‘’

๐›พ๐‘ก

14

|๐‘ฅ1 โˆ’ ๐‘ฅ2|

๐‘ฅ1

๐‘ฅ2๐œ‰ ๐‘ฅ2, ๐‘ก

๐œ‰ ๐‘ฅ1, ๐‘ก

โ‰ค ๐พ ๐‘ฅ1 โˆ’ ๐‘ฅ2 ๐‘’๐›พ๐‘ก1

= ๐พ ๐‘ฅ1 โˆ’ ๐‘ฅ2 ๐‘’๐›พ๐‘ก1

Discrepancy functions are given as model annotations, i.e. โŸจ๐พ, ๐›พโŸฉ is given by the user

Page 15: C2E2: A Tool For Verifying Stateflow Models

Simulations + Discrepancy Functions = ReachTubes

๐ = ๐’“๐’†๐’‚๐’„๐’‰๐’•๐’–๐’ƒ๐’† ๐‘บ, ๐, ๐‘ป of แˆถ๐‘ฅ = ๐‘“ ๐‘ฅ is a sequence ๐‘…0, โ€ฆ , ๐‘…๐‘˜ such that ๐‘‘๐‘–๐‘Ž(๐‘…๐‘–) โ‰ค ๐œ– and from any ๐‘ฅ0 โˆˆ ๐‘†, for each time ๐‘ก โˆˆ [๐‘–โ„Ž, (๐‘– + 1)โ„Ž], ๐œ‰ ๐‘ฅ0, ๐‘ก โˆˆ ๐‘…๐‘– .

How to compute a ReachTube from validated simulation and annotation?

๐‘†0, โ€ฆ , ๐‘†๐‘˜ , ๐œ–1 โ† ๐’—๐’‚๐’๐‘บ๐’Š๐’Ž(๐‘ฅ0, ๐‘‡, ๐‘“)

15

Page 16: C2E2: A Tool For Verifying Stateflow Models

Simulations + Discrepancy Functions = ReachTubes

๐ = ๐’“๐’†๐’‚๐’„๐’‰๐’•๐’–๐’ƒ๐’† ๐‘บ, ๐, ๐‘ป of แˆถ๐‘ฅ = ๐‘“ ๐‘ฅ is a sequence ๐‘…0, โ€ฆ , ๐‘…๐‘˜ such that ๐‘‘๐‘–๐‘Ž(๐‘…๐‘–) โ‰ค ๐œ– and from any ๐‘ฅ0 โˆˆ ๐‘†, for each time ๐‘ก โˆˆ [๐‘–โ„Ž, (๐‘– + 1)โ„Ž], ๐œ‰ ๐‘ฅ0, ๐‘ก โˆˆ ๐‘…๐‘– .

How to compute a ReachTube from validated simulation and annotation?

๐‘†0, โ€ฆ , ๐‘†๐‘˜ , ๐œ–1 โ† ๐’—๐’‚๐’๐‘บ๐’Š๐’Ž(๐‘ฅ0, ๐‘‡, ๐‘“)

For each ๐‘– โˆˆ ๐‘˜๐œ–2 โ† max

๐‘กโˆˆ๐‘‡๐‘–๐พ๐‘’๐›พ๐‘ก๐›ฟ;

๐‘…๐‘– โ† ๐ต๐œ–2 ๐‘†๐‘–

๐‘…0, โ€ฆ , ๐‘…๐‘˜ is a reachtube(๐‘ฉ๐œน ๐’™๐ŸŽ , ๐๐Ÿ + ๐๐Ÿ, ๐‘ป)

16

How do we get the simulations? How much to bloat?โ€ข How to handle mode switches?

Invariants

Guards

Page 17: C2E2: A Tool For Verifying Stateflow Models

Handling Invariants

Tagging: track a region based on a predicate ๐‘ƒ

๐’•๐’‚๐’ˆ๐‘น๐’†๐’ˆ๐’Š๐’๐’ ๐‘น,๐‘ท = แ‰๐‘š๐‘ข๐‘ ๐‘ก ๐‘… โŠ† ๐‘ƒ๐‘š๐‘Ž๐‘ฆ ๐‘… โˆฉ ๐‘ƒ โ‰  โˆ…, เดค๐‘… โˆฉ ๐‘ƒ โ‰  โˆ…๐‘›๐‘œ๐‘ก ๐‘… โˆฉ ๐‘ƒ = โˆ…

๐“ = ๐’Š๐’๐’—๐’‚๐’“๐’Š๐’‚๐’๐’•๐‘ท๐’“๐’†๐’‡๐’Š๐’™(๐, ๐‘ฐ๐’๐’—๐’‚๐’“๐’Š๐’‚๐’๐’•) is

โŸจ๐‘…0, ๐‘ก๐‘Ž๐‘”0, โ€ฆ , ๐‘…๐‘š, ๐‘ก๐‘Ž๐‘”๐‘šโŸฉ , such that either

๐‘ก๐‘Ž๐‘”๐‘– = ๐‘š๐‘ข๐‘ ๐‘ก if all the ๐‘…๐‘—โ€ฒ๐‘  before it are must

๐‘ก๐‘Ž๐‘”๐‘– = ๐‘š๐‘Ž๐‘ฆ if all the ๐‘…๐‘—โ€ฒ๐‘  before it are tagged may or must and at least one of

them is not must

17

Goal: Reachtube that respects the invariant of the mode

Page 18: C2E2: A Tool For Verifying Stateflow Models

Handling Guards & Resets

๐’๐’†๐’™๐’•๐‘น๐’†๐’ˆ๐’Š๐’๐’๐’”(๐“) returns a set of tagged regions N.

๐‘…โ€ฒ, ๐‘ก๐‘Ž๐‘”โ€ฒ โˆˆ ๐‘ iff โˆƒ ๐‘Ž โˆˆ ๐ด, โŸจ๐‘…๐‘– , ๐‘ก๐‘Ž๐‘”๐‘–โŸฉ โˆˆ ๐œ™ such that ๐‘…โ€ฒ = ๐‘…๐‘’๐‘ ๐‘’๐‘ก๐‘Ž ๐‘…๐‘– and:๐‘…๐‘– โŠ† ๐บ๐‘ข๐‘Ž๐‘Ÿ๐‘‘๐‘Ž , ๐‘ก๐‘Ž๐‘”๐‘– = ๐‘ก๐‘Ž๐‘”โ€ฒ = ๐‘š๐‘ข๐‘ ๐‘ก๐‘…๐‘– โˆฉ ๐บ๐‘ข๐‘Ž๐‘Ÿ๐‘‘๐‘Ž โ‰  โˆ…, ๐‘…๐‘– โˆ‰ ๐บ๐‘ข๐‘Ž๐‘Ÿ๐‘‘๐‘Ž , ๐‘ก๐‘Ž๐‘”๐‘– = ๐‘š๐‘ข๐‘ ๐‘ก, ๐‘ก๐‘Ž๐‘”โ€ฒ = ๐‘š๐‘Ž๐‘ฆ๐‘…๐‘– โˆฉ ๐บ๐‘ข๐‘Ž๐‘Ÿ๐‘‘๐‘Ž โ‰  โˆ…, ๐‘ก๐‘Ž๐‘”๐‘– = ๐‘ก๐‘Ž๐‘”โ€ฒ = ๐‘š๐‘Ž๐‘ฆ

Tagging is essentially bookkeeping

1. ๐‘–๐‘›๐‘ฃ๐‘Ž๐‘Ÿ๐‘–๐‘Ž๐‘›๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘“๐‘–๐‘ฅ discards the invalid trajectories (violating invariant)

2. ๐‘›๐‘’๐‘ฅ๐‘ก๐‘…๐‘’๐‘”๐‘–๐‘œ๐‘›๐‘  tags the regions based on the feasibility of discrete transition

Utility of tagging

1. Reachable set is contained in union of may and must regions โ€“ inferring safety

2. There exists at least one reachable state in every must region โ€“ inferring violation of safety

18

Goal: Compute set of states in Reachtube that change mode based on Guard

Page 19: C2E2: A Tool For Verifying Stateflow Models

Algorithm for Hybrid Systems

Input: Initial Set ฮ˜, Unsafe set ๐‘ˆ, Time ๐‘‡, Number of Switches ๐‘

๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› โ† ๐‘ก๐‘Ž๐‘”๐‘”๐‘’๐‘‘๐ถ๐‘œ๐‘ฃ๐‘’๐‘Ÿ(ฮ˜)

โˆ€ โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ โˆˆ ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘›

๐œ“ โ† ๐‘Ÿ๐‘’๐‘Ž๐‘โ„Ž๐‘‡๐‘ข๐‘๐‘’(๐‘†, ๐‘‡)

end;

19

๐‘ฅ0

Page 20: C2E2: A Tool For Verifying Stateflow Models

Algorithm for Hybrid Systems

Input: Initial Set ฮ˜, Unsafe set ๐‘ˆ, Time ๐‘‡, Number of Switches ๐‘

๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› โ† ๐‘ก๐‘Ž๐‘”๐‘”๐‘’๐‘‘๐ถ๐‘œ๐‘ฃ๐‘’๐‘Ÿ(ฮ˜)

โˆ€ โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ โˆˆ ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘›

๐œ“ โ† ๐‘Ÿ๐‘’๐‘Ž๐‘โ„Ž๐‘‡๐‘ข๐‘๐‘’(๐‘†, ๐‘‡)

๐œ™ โ† ๐‘–๐‘›๐‘ฃ๐‘Ž๐‘Ÿ๐‘–๐‘Ž๐‘›๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘“๐‘–๐‘ฅ(๐œ“)

end;

20

invariant

Page 21: C2E2: A Tool For Verifying Stateflow Models

Algorithm for Hybrid Systems

Input: Initial Set ฮ˜, Unsafe set ๐‘ˆ, Time ๐‘‡, Number of Switches ๐‘

๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› โ† ๐‘ก๐‘Ž๐‘”๐‘”๐‘’๐‘‘๐ถ๐‘œ๐‘ฃ๐‘’๐‘Ÿ(ฮ˜)

โˆ€ โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ โˆˆ ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘›

๐œ“ โ† ๐‘Ÿ๐‘’๐‘Ž๐‘โ„Ž๐‘‡๐‘ข๐‘๐‘’(๐‘†, ๐‘‡)

๐œ™ โ† ๐‘–๐‘›๐‘ฃ๐‘Ž๐‘Ÿ๐‘–๐‘Ž๐‘›๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘“๐‘–๐‘ฅ(๐œ“)

if (๐œ™ is safe) then continue;

if (๐œ™ is unsafe and ๐‘ก๐‘Ž๐‘” is ๐‘š๐‘ข๐‘ ๐‘ก) return unsafe;

else refine tagged cover;

end;

return safe;21

invariant

Page 22: C2E2: A Tool For Verifying Stateflow Models

Algorithm for Hybrid Systems

Input: Initial Set ฮ˜, Unsafe set ๐‘ˆ, Time ๐‘‡, Number of Switches ๐‘

๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› โ† ๐‘ก๐‘Ž๐‘”๐‘”๐‘’๐‘‘๐ถ๐‘œ๐‘ฃ๐‘’๐‘Ÿ(ฮ˜)

โˆ€ โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ โˆˆ ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘›

๐œ“ โ† ๐‘Ÿ๐‘’๐‘Ž๐‘โ„Ž๐‘‡๐‘ข๐‘๐‘’(๐‘†, ๐‘‡)

๐œ™ โ† ๐‘–๐‘›๐‘ฃ๐‘Ž๐‘Ÿ๐‘–๐‘Ž๐‘›๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘“๐‘–๐‘ฅ(๐œ“)

if (๐œ™ is safe) then continue;

if (๐œ™ is unsafe and ๐‘ก๐‘Ž๐‘” is ๐‘š๐‘ข๐‘ ๐‘ก) return unsafe;

else refine tagged cover;

end;

return safe;22

guard

Page 23: C2E2: A Tool For Verifying Stateflow Models

Algorithm for Hybrid Systems

Input: Initial Set ฮ˜, Unsafe set ๐‘ˆ, Time ๐‘‡, Number of Switches ๐‘

๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› โ† ๐‘ก๐‘Ž๐‘”๐‘”๐‘’๐‘‘๐ถ๐‘œ๐‘ฃ๐‘’๐‘Ÿ(ฮ˜)

โˆ€ โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ โˆˆ ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘›

๐œ“ โ† ๐‘Ÿ๐‘’๐‘Ž๐‘โ„Ž๐‘‡๐‘ข๐‘๐‘’(๐‘†, ๐‘‡)

๐œ™ โ† ๐‘–๐‘›๐‘ฃ๐‘Ž๐‘Ÿ๐‘–๐‘Ž๐‘›๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘“๐‘–๐‘ฅ(๐œ“)

๐‘๐‘’๐‘ฅ๐‘ก โ† ๐‘›๐‘’๐‘ฅ๐‘ก๐‘…๐‘’๐‘”๐‘–๐‘œ๐‘›๐‘ (๐œ™)

if (๐œ™ is safe) then check ๐‘๐‘’๐‘ฅ๐‘ก;

if (๐œ™ is unsafe and ๐‘ก๐‘Ž๐‘” is ๐‘š๐‘ข๐‘ ๐‘ก) return unsafe;

else refine tagged cover;

end;

return safe;23

guard

Page 24: C2E2: A Tool For Verifying Stateflow Models

Algorithm for Hybrid Systems

Input: Initial Set ฮ˜, Unsafe set ๐‘ˆ, Time ๐‘‡, Number of Switches ๐‘

๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› โ† ๐‘ก๐‘Ž๐‘”๐‘”๐‘’๐‘‘๐ถ๐‘œ๐‘ฃ๐‘’๐‘Ÿ(ฮ˜)

โˆ€ โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ โˆˆ ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘›

๐‘ž๐‘ข๐‘’๐‘ข๐‘’๐‘…๐‘’๐‘”๐‘–๐‘œ๐‘›๐‘  โ† {โŸจ๐‘†, ๐‘ก๐‘Ž๐‘”โŸฉ}

โˆ€ ๐‘†, ๐‘ก๐‘Ž๐‘” โˆˆ ๐‘ž๐‘ข๐‘’๐‘ข๐‘’๐‘…๐‘’๐‘”๐‘–๐‘œ๐‘›๐‘  until ๐‘ steps and ๐‘‡ time

๐œ“ โ† ๐‘Ÿ๐‘’๐‘Ž๐‘โ„Ž๐‘‡๐‘ข๐‘๐‘’(๐‘†, ๐‘‡)

๐œ™ โ† ๐‘–๐‘›๐‘ฃ๐‘Ž๐‘Ÿ๐‘–๐‘Ž๐‘›๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘“๐‘–๐‘ฅ(๐œ“)

๐‘๐‘’๐‘ฅ๐‘ก โ† ๐‘›๐‘’๐‘ฅ๐‘ก๐‘…๐‘’๐‘”๐‘–๐‘œ๐‘›๐‘ (๐œ™)

if (๐œ™ is safe) enque ๐‘๐‘’๐‘ฅ๐‘ก to ๐‘ž๐‘ข๐‘’๐‘ข๐‘’๐‘…๐‘’๐‘”๐‘–๐‘œ๐‘›๐‘ ;

if (๐œ™ is unsafe and ๐‘ก๐‘Ž๐‘” is ๐‘š๐‘ข๐‘ ๐‘ก) return unsafe;

else refine tagged cover;

end;

end;

return safe;24

guard

Page 25: C2E2: A Tool For Verifying Stateflow Models

Soundness & Relative Completeness

[Soundness]: If the algorithm returns safe(or unsafe), then the system is indeed safe(or unsafe).

Proof sketch:

1. Union of May and Must regions contains the reachable set

2. Algorithm returns safe only when all the May and Must regions are safe

3. Algorithm returns unsafe only when a Must region is contained in the unsafe set

25

Page 26: C2E2: A Tool For Verifying Stateflow Models

Soundness & Relative Completeness

[Relative Completeness]: If the system is robustly safe or robustly unsafe, then the algorithm will terminate with correct answer.

DefinitionRobustly safe: If there is ๐œ– separation between reachable set and ๐‘ˆ

Robustly unsafe: If ๐œ– shrinkage of invariants, guards, and initial set ฮ˜, is unsafewith respect to ๐œ– shrinkage of ๐‘ˆ

Proof sketch:

1. Refining the cover enough will ensure that overapproximation is less than ๐œ–, so if the system is robustly safe, the algorithm returns safe

2. If the ๐œ– shrinkage of invariants, guards, ฮ˜, and ๐‘ˆ is unsafe, then โˆƒ ๐‘…๐‘– tagged ๐‘š๐‘ข๐‘ ๐‘ก in the reachable that is unsafe

26

Page 27: C2E2: A Tool For Verifying Stateflow Models

Overview

Motivation and Problem Statement

Challenges in Verification

Building Blocks and Algorithm

Soundness and Relative Completeness Guarantees

Tool Features

Annotations

Future Work

27

Page 28: C2E2: A Tool For Verifying Stateflow Models

C2E2 :Compare-Execute-Check-Engine

Features:โ€ข Stateflow modelsโ€ข Graphical User Interfaceโ€ข Plotting

28

Architecture of C2E2

Page 29: C2E2: A Tool For Verifying Stateflow Models

๐‘ก โ‰ฅ 5; ๐‘ก = 0

C2E2: Features, Architecture, & Usability

Stateflow models: No formal semantics from MATHWORKS, Hybrid automata semantics by Tiwari [โ€˜02], Manamcheri et.al.[โ€˜10]

Urgent semantics:

Bloating the guard set: for providing robust counterexamples

๐‘ก โ‰ฅ 5 โ‡’ ๐‘ก โ‰ฅ 5 โˆ’ ๐œ–, ๐‘ก โ‰ค 5 + ๐œ–

29

Page 30: C2E2: A Tool For Verifying Stateflow Models

C2E2: Features, Architecture, & Usability

30

โ€ข GUI for viewing model, propertiesโ€ข Saving model in hyxml formatโ€ข Interface for plotting reachable set

More in the Tool Demo Market

Page 31: C2E2: A Tool For Verifying Stateflow Models

Comparison with Existing Approaches on Academic Benchmarks [DMVโ€™13]

31

Benchmark Variables Sims. C2E2(time)

Flow*(time)

Ariadne(time)

Moore-G. Jet Engine 2 36 1.56 10.54 56.57

BrussellatorSystem 2 115 5.26 16.77 72.75

VanDerPolOscillator 2 17 0.75 8.93 98.36

Coupled VanDerPol 4 62 1.43 90.96 270.61

Sinusoidal Tracking 6 84 3.68 48.63 763.32

Linear Adaptive 3 16 0.47 NA NA

Nonlinear Adaptive 2 32 1.23 NA NA

Nonlinear Disturbance 3 48 1.52 NA NA

C2E2 Flow*

Page 32: C2E2: A Tool For Verifying Stateflow Models

Discrepancy Functions โ€“ Model Annotations

Sufficient conditions for finding discrepancy functions (borrowed from Control Theory)โ€ข Lipschitz continuity: แˆถ๐‘ฅ = ๐‘“(๐‘ฅ) has Lipschitz constant ๐ฟ, then ๐‘ฅ1(๐‘ก) โˆ’ ๐‘ฅ2(๐‘ก) โ‰ค |๐‘ฅ1 โˆ’ ๐‘ฅ2|๐‘’

๐ฟ๐‘ก

โ€ข Contraction Metric: If ๐ฝ๐‘‡๐‘€+๐‘€ ๐ฝ + ๐‘๐‘€๐‘€ โ‰ผ 0, then โˆƒ๐‘˜, ๐›ฟ > 0, ๐‘ฅ1 ๐‘ก โˆ’ ๐‘ฅ2 ๐‘ก 2 โ‰ค ๐‘˜ ๐‘ฅ1 โˆ’ ๐‘ฅ22๐‘’โˆ’๐›ฟ๐‘ก

โ€ข Incremental Lyapunov Function: With function ๐‘‰, then ๐‘ฅ1 ๐‘ก โˆ’ ๐‘ฅ2(๐‘ก) โ‰ค ๐‘˜ ๐‘ฅ1 โˆ’ ๐‘ฅ2 ; ๐‘˜ = ๐น(๐‘‰)

Finding such discrepancy function automaticallyโ€ข Nonlinear optimization for Lipschitz continuityโ€ข For แˆถ๐‘ฃ = ๐ด๐‘ฃ that are exponentially stable, compute Lyapunov functionโ€ข Solving LMIs using Sum-Of-Squares tools to compute contraction metricโ€ข Manual proof methods using coordinate transformation and eigen values of Jacobian 32

Exponential discrepancy functionโŸจ๐พ = 3.8, ๐›พ = โˆ’0.2โŸฉ

Page 33: C2E2: A Tool For Verifying Stateflow Models

Summary & Future Work

Simulation based verification algorithm for Fully Hybrid Systems

Soundness and Relative completeness guarantees

Tool features:โ€ข Stateflow modelsโ€ข GUI and usability enhancementsโ€ข Plotting for visualizing reachable set

Future Work

Automatically finding discrepancy functions

Theoretical Result: Minimum number of simulations to verify a given system

33Thank You, Questions?