analysis contracts for cps - ls.cs.cmu.edu
TRANSCRIPT
Analysis Contracts for CPS
Presenter: Dionisio de Niz1
CPS V&V Workshop
Team: Ivan Ruchkin2, Sagar Chaki1,
David Garlan2
1Software Engineering Institute & 2School of Computer Science
2
Copyright 2014 Carnegie Mellon University This material is based upon work funded and supported by the Department of Defense under Contract No. FA8721-05-C-0003 with Carnegie Mellon University for the operation of the Software Engineering Institute, a federally funded research and development center. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the United States Department of Defense. NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN โAS-ISโ BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. This material has been approved for public release and unlimited distribution except as restricted below. This material may be reproduced in its entirety, without modification, and freely distributed in written or electronic form without requesting formal permission. Permission is required for any other use. Requests for permission should be directed to the Software Engineering Institute at [email protected]. Carnegie Mellonยฎ is registered in the U.S. Patent and Trademark Office by Carnegie Mellon University. DM-0001998
3
Motivation
The development of Cyber-Physical Systems (aircrafts, cars, trains, robots, etc.) increasingly relies on many types of analyses from different disciplines for assurance purposes
โข Control stability, scheduling, logic, thermal, power, aerodynamics, etc.
Large CPS are integrated out of components developed by suppliers that use their own analysis methods and make their own assumptions
Analysis assumption mismatches are discovered late in the system integration phase
โข Difficult and costly to solve
4
Boeing 787 Suppliers
Kawasaki
Spirit
Saab
Goodrich
Rolls Royce
Boeing Australia
Mitsubishi
Boeing US Alenia
Alenia
KAL-ASD
Latecoere
Source: Boeing / Reuters
5
Inter-Domain Analyses Interactions
Cha
rge
Dis
ch
arg
e
Source: National Renewable Energy Laboratory
main(){
for(i=0;;)
โฆ
}
main(){
for(i=0;;)
โฆ
}
main(){
for(i=0;;)
โฆ
}
Scheduling +
Frequency
Scaling
Battery Recharge Scheduling
Selected
Voltage Cell Interconnects
Thermal Runaway Analysis
6
Analysis Contracts
Sensor
Sampling
PID
Controller
Actuator
Controller
Sensor
Board CPU
Actuator
Board
Comm Protocol (reliable/unreliable)
Control Stability Schedulability
Pow
er
Exec T
ime
Frequency Scaling
Discharge Charge
Battery Sched
Tem
p
Thermal runaway
Assumption
Guarantee
Read/write Read/write
Read/w
rite
R
ead/w
rite
deadlock
Model checking
Read/write
AADL
7
Analysis Contracts Structure
AADL Model
Domain (e.g. in SPIN)
Analysis
Plugin Analysis
Plugin
Domain (e.g. in SMT)
Analysis
Plugin Analysis
Plugin
Contract
(Annex) Contract
(Annex)
Contract
(Annex)
Contract
(Annex)
8
Contract Semantic Basis
Domain (๐, ๐ฎ, โ, ๐ฏ, โ ๐)
โข Sorts ๐ = ๐ด1, ๐ด2, โฆ , e.g. Booleans, Integers, Threads, Priorities
โข Static Properties : ๐ฎ = ๐๐ , ๐๐: ๐ด1 ร โฏ ร ๐ด๐ โฆ ๐ด๐
โ Design-time invariants, Regular operators: (โง, โฌ ร โฌ โฆ โฌ)
โข Runtime Properties : โ = ๐ ๐ , ๐ ๐: ๐ด1 ร โฏ ร ๐ด๐ โฆ ๐ด๐
โ Evolving valuation at different states q: q(๐ ๐)
โข Domain execution semantics: ๐ฏ
โ Infinite sequence of assignments to runtime properties (executions)
โข Domain interpretation of sorts/static properties: โ ๐
โ E.g. allowed schedulers, some left uninterpreted
Architectural Model Interpretation: โ ๐ on ๐, ๐ฎ, ๐ฏ
โข E.g. threads and periods: ๐ ๐ = ๐ก1, ๐ก2 ; ๐๐๐ ๐ = {๐ก1 โฆ 10, ๐ก2 โฆ 20}
Executions of system defined by M: ๐ฏ ๐
โข Combining โ ๐ , โ ๐ into โ
โข Each state q in possible states Q maps ๐ ๐ to function ๐ ๐ ๐ : ๐ด1 ร โฏ ร ๐ด๐ โฆ ๐ด๐
โข With all infinite sequence of states ๐๐
โข ๐ฏ ๐ โ ๐๐
9
Contract Language
Contract formulas
โข Given domain ๐ = (๐, ๐ฎ, โ, ๐ฏ, โ ๐),
โข โฑ๐ โท= โ ๐ฃ1, โฆ , ๐ฃ๐ โ ๐ โ ๐ฃ1, โฆ , ๐ฃ๐ โ ๐ โ ๐ฃ1, โฆ , ๐ฃ๐ โ ๐: ๐|โ๐ฃ1, โฆ , ๐ฃ๐ โ ๐: ๐
โ ๐ฃ๐: ๐ด๐, ๐: static (first order) formula
โ ๐ : LTL formula
Contract ๐ถ = (๐ผ, ๐, ๐ด, ๐บ)
โข ๐ผ โ (๐ โช ๐ฎ): Sorts and properties read by the analysis
โข ๐ โ (๐ โช ๐ฎ): Sorts and properties written by the analysis
โข ๐ด โ โฑ๐: assumptions: must be true in input
โข ๐บ โ โฑ๐: guarantees: must be true in output
10
Contract Verification
Given model M and set of analyses ๐๐ฉ = {๐ด๐๐}:
โข For ๐ด๐๐ . ๐ถ = ๐ผ, ๐, ๐ด, ๐บ : M application to ๐ด๐๐ iff
โ โ ๐ โ ๐ด โ ๐ โจ ๐, โ ๐ โ ๐บ โ Ani M โจ ๐
Valid analysis ordering: no dependencies from later analysis
โข Contract (& analysis) dependency: d Ci, Cj : Ci. I โฉ ๐ถ๐ . ๐ โ โ
Contract Formulas
โข First order: in SMT (Z3)
โข LTL : Model checker
โข FOL + LTL: Generate all solutions for FOL, check LTL in each
11
Example: Surveillance Aircraft
Analysis
Security: tasks of different level
to different processor
Scheduling: meet all deadlines
Freq. Scaling: minimize power
Logic: no deadlocks or race
conditions
Battery scheduling: meet
battery lifetime
Battery thermal: no runaways
main(){
for(i=0;;)
โฆ
}
main(){
for(i=0;;)
โฆ
}
main(){
for(i=0;;)
โฆ
}
Security: Top Secret Security: Secret
Battery
Software
Processors
12
Surveillance Aircraft Contracts
Security Analysis
โข ๐ด๐๐ ๐๐ . ๐ถ: ๐ผ = ๐, ๐โ๐๐๐๐ถ๐ , ๐ = ๐๐๐ก๐ถ๐๐๐๐ , ๐ด = โ , ๐บ = {๐}
โ ๐: โ ๐ก1, ๐ก2 โ ๐โ๐๐๐๐ถ๐ ๐ก1 โ ๐โ๐๐๐๐ถ๐ ๐ก2 โ ๐ก1 โ ๐๐๐ก๐ถ๐๐๐๐(๐ก2)
Multiprocessor scheduling: (Binpacking + scheduling)
โข ๐ด๐๐ ๐โ๐๐ . ๐ถ: ๐ผ = ๐, ๐ถ, ๐๐๐ก๐ถ๐๐๐๐, ๐๐๐, ๐๐ถ๐ธ๐, ๐ท๐๐๐๐ , ๐ = ๐ถ๐๐๐ต๐๐๐ , ๐ด = โ , ๐บ = {๐}
โ ๐: โ ๐ก1, ๐ก2 โ ๐ก1 โ ๐๐๐ก๐ถ๐๐๐๐ ๐ก2 โ ๐ถ๐๐๐ต๐๐๐ ๐ก1 โ ๐ถ๐๐๐ต๐๐๐(๐ก2)
Frequency Scaling
โข ๐ด๐๐๐๐๐๐ ๐ . ๐ถ: ๐ผ = ๐, ๐ถ, ๐ถ๐๐๐ต๐๐๐, ๐ท๐๐๐๐ , ๐ = ๐ถ๐๐๐น๐๐๐ , ๐บ = โ , ๐ด = {๐}
โ ๐: โ๐ก1, ๐ก2 โ ๐ถ๐๐๐ต๐๐๐ ๐ก1 = ๐ถ๐๐๐ต๐๐๐ ๐ก2 : ๐บ(๐ถ๐๐๐๐๐๐๐ก ๐ก1, ๐ก2 โ ๐ท๐๐๐๐ ๐ก1 < ๐ท๐๐๐๐(๐ก2)
Model checking periodic program (REK):
โข ๐ด๐๐๐๐. ๐ถ: ๐ผ = ๐, ๐ถ, ๐๐๐, ๐ท๐๐๐๐, ๐๐ถ๐ธ๐, ๐ถ๐๐๐ต๐๐๐ , ๐ = ๐โ๐๐๐๐ , ๐บ = โ , ๐ด = {๐1, ๐2}
โข ๐1: โ๐ก โ ๐๐๐ ๐ก = ๐ท๐๐๐๐ ๐ก , ๐2: โ๐ก1, ๐ก2 โ ๐บ(๐ถ๐๐๐๐๐๐๐ก ๐ก1, ๐ก2 โ ๐บ ยฌ๐ถ๐๐๐๐๐๐๐ก ๐ก2, ๐ก1 )
Thermal runaway:
โข ๐ด๐๐กโ๐๐๐ . ๐ถ: ๐ผ = ๐ต, ๐ต๐๐ก๐ ๐๐ค๐ , ๐ต๐๐ก๐ถ๐๐๐ , ๐๐๐๐ก๐๐๐ , ๐ = ๐พ , ๐ด = โ , ๐บ = โ
Battery Scheduling
โข ๐ด๐๐๐ ๐โ๐๐ . ๐ถ: ๐ผ = ๐ต, ๐ต๐๐ก๐ ๐๐ค๐ , ๐ต๐๐ก๐ถ๐๐๐ , ๐ = ๐ต๐๐ก๐ถ๐๐๐๐๐โ๐๐๐๐๐, ๐ป๐๐ ๐ ๐๐๐ฟ๐๐๐๐ก๐๐๐, ๐๐๐๐๐๐๐ ๐๐, ๐๐๐๐๐๐ ๐๐ , ๐ด = โ , ๐บ ={๐}
โข ๐: ๐บ(๐พ 0 ร ๐๐ 0 + ๐พ 1 ร ๐๐ 1 + ๐พ 2 ร ๐๐ 2 + ๐พ 3 ร ๐๐ 3 โฅ 0)
13
Satisfying Assumptions in Specific System: Frequency Scaling
๐: โ๐ก1, ๐ก2 โ ๐ถ๐๐๐ต๐๐๐ ๐ก1 = ๐ถ๐๐๐ต๐๐๐ ๐ก2 : ๐บ(๐ถ๐๐๐๐๐๐๐ก ๐ก1, ๐ก2 โ ๐ท๐๐๐๐ ๐ก1 < ๐ท๐๐๐๐(๐ก2)
P D
P=D
P=D
P=D
DMSโ RMS
DMS=RMS
EDFโ RMS
EDF=RMS
P=D, Harmonic, Sync
14
Satisfying Assumptions in Specific System: Battery Scheduling Assumption
๐: ๐บ(๐พ 0 ร ๐๐ 0 + ๐พ 1 ร ๐๐ 1 + ๐พ 2 ร ๐๐ 2 + ๐พ 3 ร ๐๐ 3 โฅ 0)
Cells w 1 neighbors TN(1)
Cells w 2 neighbors TN(2)
Cells
w 3
neig
hbors
TN
(3)
Ratio of cells with 0,1,2,3 neighbors: 1 โ ๐๐ 1 โ 1 โ ๐๐ 2 + 10 โ ๐๐ 3 โฅ0
1 โ 4 โ 1 โ 10 + 10 โ 2 = 14 โฅ 0 1 โ 2 โ 1 โ 14 + 10 โ 0 = โ12 < 0
15
ACTIVE Tool
Plugins for OSATE that consist of
Contract Annex Sublanguage (Parser)
โข Captures analysis contracts within AADL models
ACTIVE Executer
โข Interprets contracts and identifies valid execution schedules
ACTIVE Verifier
โข Identifies and run contract verification engines
16
Analysis Contract Annex
package Contracts
public
with Contract_Properties, SEI, Deployment_Properties;
annex contract {**
name SecureAllocationAnalysis
input thread, thread.SecurityLevel
output thread.Not_Colocated
guarantees
forall x1: thread, x2:thread :
x1 != x2 -> (x1.SecurityLevel = x2.SecurityLevel) || x1 in x2.Not_Colocated
โฆ
**};
end Contracts;
package AircraftPackage
public
with Contract;
system implementation AircraftSystem.i
โฆ
annex contract {**
use contracts::SecureAllocationAnalysis,
contracts::BinPackingAnalysis,
โฆ
**};
end AircraftSystem.i;
end AircraftPackage;
17
Analysis Contract Annex Examples
name LlrekAnalysis
input thread, thread.Period, thread.Deadline,
thread.Source_Text, thread.Priority,
thread.Compute_Execution_Time,
thread.Priority,
thread.Actual_Processor_Binding
output system.Is_Thread_Safe
assumes
forall t: thread : t.Period = t.Deadline
assumes
forall t1:thread, t2: thread | t1 != t2 :
G (CanPreempt(t1, t2) =>
(G!CanPreempt(t2, t1)))
name BatterySchedulingAnalysis
input device, device.Cell_Rows,
device.Cell_Cols, device.K0, device.K1,
device.K2, device.K3,
processor.Current_Frequency
output device.Serial_Req, device.Paral_Req,
device.Bat_Scheduler
guarantees
forall b: device :
G (b.K0 * b.TN(0) + b.K1*b.TN(1) +
b.K2*b.TN(2) + b.K3*b.TN(3) >= 0 )
18
ACTIVE Executer
Responsibilities
โข Parse โuseโ subclauses in scope
โข Retrieve referred contracts from
libraries
โข Create dependency graph
* no cycle support
โข Correct sequence of execution
of analysis and verifiers
โข Plugin wrappers to prevent
compiling dependencies
+ Monitors plugin completion
19
ACTIVE Verifier
Decompose contract formulas into segments verifiable by single verifier
1. <Quan><Var><Predicate Expression>
โ e.g.: forall t:thread | t.Period = t.Deadline
โ sent to SMT solver. Each solution is later blocked to get all solutions
โ Identifies part of model that should be verified
2. <LTLExpression>
โ Identify domain atoms and functions: e.g. thread, CanPreempt()
โ Select verifier that can interpret all atoms, functions, and operators
โ Translate AADL model into verifier data (e.g. threads, periods,
scheduler, etc.)
โ Run verifier
โ Interpret and put results back into AADL model
20
Conclusions
Analyses from multiple domains are key for development of CPS
โข But inconsistent assumptions may compromise results
Analysis contracts to automatically verify assumptions
โข Analysis contract language & verification framework
โข Implementation in AADL sub-annex
ACTIVE (Analysis ContracT Integration VErifier) Tool
โข Extensible
โข ACTIVE Executer + ACTIVE Verifier
Tested on two domains and five analyses