systematic derivation of static analyses for software product lines

50
VARIETE workshop, ITU Variational Abstract Interpretation Nov 28, 2013 Claus Brabrand IT University of Copenhagen Jan Midtgaard Aarhus Universtity Andrzej Wasowski IT University of Copenha Systematic Derivation of Static Analyses for Software Product Lines VAR . ABS . INT

Upload: kana

Post on 22-Feb-2016

23 views

Category:

Documents


0 download

DESCRIPTION

V AR . A BS . I NT. Systematic Derivation of Static Analyses for Software Product Lines. Jan Midtgaard Aarhus Universtity. Claus Brabrand IT University of Copenhagen. Andrzej Wasowski IT University of Copenhagen. < Outline >. Introduction The ' IMP ' and ' IMP ' Language s - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Systematic Derivation  of Static Analyses  for Software Product Lines

VARIETE workshop, ITU Variational Abstract Interpretation Nov 28, 2013

Claus BrabrandIT University of Copenhagen

Jan MidtgaardAarhus Universtity

Andrzej WasowskiIT University of Copenhagen

Systematic Derivation ofStatic Analyses forSoftware Product LinesVAR.ABS.INT

Page 2: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 4 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

< Outline >

IntroductionThe 'IMP' and 'IMP' LanguagesAbstract Interpretation of IMPVariational Abstract Interpretation of IMPRelated WorkConclusion

Page 3: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 5 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

IntroductionSoftware Product Lines:

Brute force analysis:

x := 0; #ifdef INC x := x + 1; #endif #ifdef NEG x := -x; #endif output x;

x := 0;

output x;

x := 0; x := x + 1;

output x;

x := 0;

x := -x; output x;

x := 0; x := x + 1; x := -x; output x;

x is 0

x is 1

x is -0

x is -1

Ø: {INC}: {NEG}: {INC,NEG}:

generateO(n = 2|F|)

analyze analyze analyze analyze

"generate'n'analyze"

...

Page 4: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 6 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Analyses for SPLsAnalyses for SPLs (lifted analysis):

Previous work on:How to lift:

...efficiently:

"Intraprocedural Dataflow Analysis for Software Product Lines" ( Brabrand, Ribeiro, Toledo, Winther, Borba ) TAOSD 2012

"SPLLIFT: Statically Analyzing Software Product Lines in Minutes instead of Years" ( Bodden, Toledo, Ribeiro, Brabrand, Borba, Mezini ) PLDI 2013

x := 0; #ifdef INC x := x + 1; #endif #ifdef NEG x := -x; #endif output x;

{INC}: x is 1Ø & {NEG}: x is 0{INC,NEG}: x is -1

analyze SPL directly!

Page 5: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 7 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

MotivationSystematic liftingof other static analyses:

Correctness: derivation of correct SPL analyses:

Approximation in theanalyses on variability:

Understanding space offamily-based analyses:

x := 0; #ifdef INC x := x + 1; #endif #ifdef NEG x := -x; #endif output x;

{INC}: x is 1Ø & {NEG}: x is 0{INC,NEG}: x is -1

Systematicderivation

?

x := 0; #ifdef XYZ x := x + 1; #endif #ifdef XYZ x := -x; #endif output x;

Understanding?

LiftedanalysisLiftedlanguage

analysislanguage

Correctness

of analysis?

Ø: x is 0{XYZ}: x is

Approximate

variability?

Lifted...■control-flow analysis?■dataflow analysis?■model checking?■type systems?■verification?■testing?■...?

Page 6: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 8 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Abstract InterpretationThe Abstract Interpretation Process:

Collecting Semantics: Approximate Analysis: Constant Propagation:C B A

No approximation(Undecidable)

Some approximation(Undecidable)

More approximation(Decidable!)derive derive

Page 7: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 9 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Variational Abstract Interpretation

LIFT

Abstract Interpretation: Abstract Interpretation:

LIFT LIFT LIFTLIFT LIFT

SPL

Variational

Page 8: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 10 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Motivation: 'Var.Abs.Int'Systematic lifting ofother kinds of analyses:

Correctness: derivation of correct SPL analyses:

Approximation in theanalyses on variability:

Understanding space offamily-based analyses:

Correctnessof

analyses!Systemati

cderivation!

Approximate

variability!Understanding

!

Lifted...■control-flow analysis?■dataflow analysis?■model checking?■type systems?■verification?■testing?■...?

Page 9: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 11 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

< Outline >

IntroductionThe 'IMP' and 'IMP' LanguagesAbstract Interpretation of IMPVariational Abstract Interpretation of IMPRelated WorkConclusion

Page 10: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 12 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

'IMP'Syntax:

Semantics (small-step SOS):

Page 11: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 13 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

'IMP'Syntax of (two-staged) IMP:

Set of Features:Configurations:

Satisfiability of '#if' formulae, :

x := 0; #if INC x := x + 1; #endif #if NEG x := -x; #endif output x;

= { INC, NEG }

= { Ø, {INC}, {NEG}, {INC,NEG} }

k = {NEG}

Page 12: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 14 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

'IMP'Semantics via preprocessor: x := 0;

#if INC x := x + 1; #endif #if NEG x := -x; #endif output x;

x := 0;

x := -x; output x;

{NEG}:

k = {NEG}

P : IMP × ➞ IMP

Page 13: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 15 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

< Outline >

IntroductionThe 'IMP' and 'IMP' LanguagesAbstract Interpretation of IMPVariational Abstract Interpretation of IMPRelated WorkConclusion

Page 14: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 16 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Starting Point:SOS Semantics:

CStore Store➞

Like Semantics, but working on sets of stores!Undecidable analysis prepared for subsequent approximation

Collecting Semantics:

2Store 2➞ Store

...ordered by ' '⊆

Page 15: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 17 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Galois ConnectionGalois Connection:

Pair of functions:abstraction:concretization:

Satisfying:

relatingtwo domains

viaabstraction!(wrt info lossbtwn them)

Page 16: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 18 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Galois ConnectionLots of interesting properties:

Page 17: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 19 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

AbstractionFrom functions on C to functions on A:

Define 'F : A ➞ A' in terms of 'f : C ➞ C'1) concretize2) apply ' f '3) abstract

Hence:

Page 18: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 20 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

GC from C to B...A specific Galois Connection:

Sets-of-Stores:2Store = 2Var Val➞

AbstractStore:Var 2➞ Val

abstract

output x*y;{ 2 }

output x*y;{ 1, 2,

4 }⊆

Page 19: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 21 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

From C to B !

BC

Collecting Semantics:

Approximate Analysis:(2Var Val➞ ) ➞ (2Var Val➞ )

(Var 2➞ Val) (Var 2➞ ➞ Val)Note: independent of C !

Page 20: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 22 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Derivation: C to BSystematic derivation: from C[if] to B[if] !

NB: This is also proof of correctness:

B = α ◦ C ◦

γ

expand definition of

C

β reduction

α is a CJM

overapproximation:C and α monotone

function composition

IH: B = α ◦ C ◦ γ

Note: independent of C !

Page 21: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 23 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

From C to B !

BC

Collecting Semantics:

Approximate Analysis:(2Var Val➞ ) ➞ (2Var Val➞ )

(Var 2➞ Val) (Var 2➞ ➞ Val)Note: independent of C !Note': Still undecidable analysis!

Page 22: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 24 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

GC from B to A...Another specific Galois Connection:

abstractb =[ x {1,2}, y {1} ]

a = αBA(b) =[ x , y 1 ]

Page 23: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 25 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

From B to A !

BApproximate Analysis:

(Var 2➞ Val) (Var 2➞ ➞ Val)

(Var Const) (Var Const)➞ ➞ ➞

AConstant Propagation:

Note: independent of B !

Page 24: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 26 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Derivation: B to ASystematic derivation: from B[if] to A[if] !

NB: Again, this is also proof of correctness:Note: independent of B !

Soundness:Transitively

Page 25: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 27 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

From B to A !

BApproximate Analysis:

(Var 2➞ Val) (Var 2➞ ➞ Val)

(Var Const) (Var Const)➞ ➞ ➞

AConstant Propagation:

Note: independent of B !

Note': decidable analysis!

Page 26: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 28 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Extracting Dataflow EquationsConstant propagation analysis:

ADataflow Equations:

Page 27: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 29 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

< Outline >

IntroductionThe 'IMP' and 'IMP' LanguagesAbstract Interpretation of IMPVariational Abstract Interpretation of IMPRelated WorkConclusion

Page 28: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 30 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Lifting DomainsA domain:

is lifted to:

where

Page 29: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 31 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Lifting GC'sLifting Galois Connections:

Note: Pointwise lifting

Page 30: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 32 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Lifting State Xformers1 Complex Function

Problems:Interference! (tuples not independent)Complicate proofs!

|K| Simple Functions

Well-behaved subset of

Independent functions!Intuition: runanalyses in parallel

✔However, (ab)use this notation !!!

...vs...

Page 31: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 33 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Lifting State XformersStraightforward way of analyzing config, k:

Note: we end up at the bottom of the diagram!

Page 32: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 34 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Lifting State XformersStraightforward way of analyzing config, k:

LIFT: Simply apply to all :

Page 33: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 35 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

From A to A !Constant Propagation:

(Var Const) (Var Const)➞ ➞ ➞

A LiftedConstant Propagation:

(Var Const)➞ K (Var Const)➞ ➞ K

A

Note: independent of A !

Page 34: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 36 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Derivation: A to ASystematic derivation: from A[if] to A[if] !

NB: Again, this is also proof of correctness!Note: independent of A !

Page 35: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 37 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

From A to A !Constant Propagation:

(Var Const) (Var Const)➞ ➞ ➞

A LiftedConstant Propagation:

(Var Const)➞ K (Var Const)➞ ➞ K

A

Note: independent of A !

Page 36: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 38 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Lifted Dataflow EquationsLifted Constant Propagation:

A Lifted Dataflow Equations:

Soundness:

Page 37: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 39 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Overview: 'Var.Abs.Int'

CommutingDiagram !!!

Page 38: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 40 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Contributions: 'Var.Abs.Int'Systematic lifting ofother kinds of analyses:

Correctness: derivation of correct SPL analyses:

Approximation in theanalyses on variability:

Understanding space offamily-based analyses:

Correctnessof

analyses!Systemati

cderivation!

Approximate

variability!Understanding

!

Lifted...■control-flow analysis?■dataflow analysis?■model checking?■type systems?■verification?■testing?■...?

Page 39: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 41 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

< Outline >

IntroductionThe 'IMP' and 'IMP' LanguagesAbstract Interpretation of IMPVariational Abstract Interpretation of IMPRelated WorkConclusion

Page 40: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 42 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Related WorkLifting representations:

Lifting dataflow analysis:

Lifting other analyses:(see citations in paper)

"The Choice Calculus: A Representation for Software Variation"( Erwig, Walkingshaw ) TOSEM 2011

"Intraprocedural Dataflow Analysis for Software Product Lines" ( Brabrand, Ribeiro, Toledo, Winther, Borba ) TAOSD 2012

"SPLLIFT: Statically Analyzing Software Product Lines in Minutes instead of Years" ( Bodden, Toledo, Ribeiro, Brabrand, Borba, Mezini ) PLDI 2013

"Variability-Aware Parsing in the Presence of Lexical Macros and Cond. Compilation" ( Kastner, Giarrusso, Rendel, Erdweg, Ostermann, Berger ) OOPSLA 2011

■Type systems■Well-formedness checking■Model checking■Verification■Testing

Page 41: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 43 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Related Work (cont'd)Multi-staged program analysis:

Abstract Interpretation:

"Static Analysis of Multi-Staged Programs via Unstaging Translation"( Choi, Aktemur, Yi, Tatsuta ) SIGPLAN Not., 2011

"Two-Level Functional Languages"( Nielson, Nielson ) Tracts in Theoretical Computer Science, 1992

"The Calculational Design of a Generic Abstract Interpreter"( Cousot ) Calculational System Design, 1999

"Systematic Design of Program Analysis Frameworks"( Cousot, Cousot ) POPL 1979

"Calculating Graph Algorithms for Dominance and Shortest Path"( Sergey, Midtgaard, Clarke ) MPC 2012

"A Structural Soundness Proof for Shivers’s Escape Technique: ..."( Midtgaard, Adams, Might ) SAS 2012

Page 42: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 44 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

< Outline >

IntroductionThe 'IMP' and 'IMP' LanguagesAbstract Interpretation of IMPVariational Abstract Interpretation of IMPRelated WorkConclusion

Page 43: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 45 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Conclusion: 'Var.Abs.Int'Systematic lifting ofother kinds of analyses:

Correctness: derivation of correct SPL analyses:

Approximation in theanalyses on variability:

Understanding space offamily-based analyses:

Correctnessof

analyses!Systemati

cderivation!

Approximate

variability!Understanding

!

Lifted...■control-flow analysis?■dataflow analysis?■model checking?■type systems?■verification?■testing?■...?

Page 44: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 46 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

Learn More...Read (and cite) our Paper:

Including 35 page Appendix (p. 13 – 47):Apx A:

Prerequisite Mathematics

Apx B:Proof overview

Apx C – P:Proofs

"Systematic Derivation of Static Analyses for Software Product Lines" ( Jan Midtgaard, Claus Brabrand, Andrzej Wasowski ) Submitted for publication

Page 45: Systematic Derivation  of Static Analyses  for Software Product Lines

VARIETE workshop, ITU Variational Abstract Interpretation Nov 28, 2013

( THANKS )

Page 46: Systematic Derivation  of Static Analyses  for Software Product Lines

VARIETE workshop, ITU Variational Abstract Interpretation Nov 28, 2013

BONUS SLIDES

Page 47: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 49 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

The 'Var.Abs.Int' MethodologyBASE (classic abstract interpretation):

1) Develop formal SOS semantics2) Devise collecting semantics3) Compose GC's and derive until "good analysis"

LIFT (from program to program families):4) Extend language with preprocessor5) Apply lifting combinator to get to family level6) Simplify to direct expression for lifted analysis–) Correctness (soundness) follows by construction

Variability abstractions:v1) Decide when to lift to program familiesv2) Apply lifting combinator to get to family levelv3) Devise GC's that abstract configuration space!v4) Simplify to direct expression for lifted analysis ++v–) Correctness (soundness) follows by construction

Page 48: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 50 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

independent options...

(233) > Earth's Population

[ C. K

ästn

er ]

33

Page 49: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 51 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU(2320) > Atoms in Universe

[ C. K

ästn

er ]

independent options...320

Page 50: Systematic Derivation  of Static Analyses  for Software Product Lines

[ 52 ]Variational Abstract Interpretation Nov 28, 2013VARIETE workshop, ITU

[ C. K

ästn

er ]

10 000 configurableoptions...

(210 000): Really BIG Bumber