SLIDE 1 Feature Diagrams & Logic There and Back Again
Krzysztof Czarnecki
University of Waterloo
Andrzej W ˛ asowski
IT University of Copenhagen
SLIDE 2 Feature Models
car
SLIDE 3 Feature Models
car power-locks keyless-entry gear engine body
SLIDE 4 Feature Models
car power-locks keyless-entry gear engine body electric gas manual automatic
SLIDE 5 Feature Models
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
SLIDE 6 Feature Models
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
Model variability & commonality.
SLIDE 7 Feature Models
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
Model variability & commonality. Standard semantics:
φ(car, body, engine, gear, . . . )
SLIDE 8 Semantics
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
φ
SLIDE 9
Reverse Engineering Syntax
?
φ
SLIDE 10 Reverse Engineering Syntax
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
φ
SLIDE 11 Reverse Engineering Syntax
a → c a b c c a b a b c a, c b
φ
SLIDE 12 Reverse Engineering Syntax
a b c
φ
SLIDE 13
Contents
Motivation Syntax & Semantics (going there) Algorithm (going back again) Concluding remarks
SLIDE 14
Contents
Motivation Syntax & Semantics (going there) Algorithm (going back again) Concluding remarks
SLIDE 15
Theoretical Motivation
To deepen understanding of feature models To explore the relation between logics and FMs To characterize formulæ that are FMs without leftover constraint
SLIDE 16
Applied Motivation
To visualize variability given as systems of constraints.
SLIDE 17
Applied Motivation
To visualize variability given as systems of constraints. To guide the user interactively in visualizing constraints.
SLIDE 18
Applied Motivation
To visualize variability given as systems of constraints. To guide the user interactively in visualizing constraints. To support refactoring tools.
SLIDE 19
Applied Motivation
To visualize variability given as systems of constraints. To guide the user interactively in visualizing constraints. To support refactoring tools. To support reverse engineering FMs from code.
SLIDE 20
Contents
Motivation Syntax & Semantics (going there) Algorithm (going back again) Concluding remarks
SLIDE 21 Syntax: Going There
f
Solitary [1..1] → mandatory
SLIDE 22 Syntax: Going There
f
Solitary [1..1] → mandatory
f
Solitary [0..1] → optional
SLIDE 23 Syntax: Going There
f
Solitary [1..1] → mandatory
f
Solitary [0..1] → optional
f
Solitary [0..1] → grouped
SLIDE 24 Syntax: Going There
f
Solitary [1..1] → mandatory
f
Solitary [0..1] → optional
f
Solitary [0..1] → grouped Group [1..1] → xor-group
SLIDE 25 Syntax: Going There
f
Solitary [1..1] → mandatory
f
Solitary [0..1] → optional
f
Solitary [0..1] → grouped Group [1..1] → xor-group Group [1..k] → or-group
SLIDE 26 Syntax: Going There
f
Solitary [1..1] → mandatory
f
Solitary [0..1] → optional
f
Solitary [0..1] → grouped Group [1..1] → xor-group Group [1..k] → or-group
φ
Left-over constraints
SLIDE 27 Semantics: Going There
a b c d e f
a b c d e f
∧
a c ∨ e f
SLIDE 28 Semantics: Going There
a b c d e f
a b c d e f
∧
a c ∨ e f
a b c d ∨ e f
An implication (hyper)graph
SLIDE 29
Contents
Motivation Syntax & Semantics (going there) Algorithm (going back again) Concluding remarks
SLIDE 30
Why Is It So Hard?
1. Possibly no models corresponding to φ
SLIDE 31 Why Is It So Hard?
1. Possibly no models corresponding to φ 2. Possibly many models corresponding to φ
a → c a b c c a b a b c a, c b
SLIDE 32 Why Is It So Hard?
1. Possibly no models corresponding to φ 2. Possibly many models corresponding to φ
a → c a b c c a b a b c a, c b
3. Brute-force infeasible
SLIDE 33 Root Feature
Property The root of a feature tree Test A variable r implied by all the
for all i. φ → (fi → r)
SLIDE 34 Root Feature
Property The root of a feature tree Test A variable r implied by all the
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
body → car, gas → car, . . .
SLIDE 35
Feature Hierarchy
Property
f is an ancestor of g (descendant)
Test Implication from descendant (g) to ancestor (f)
g → f
SLIDE 36 Feature Hierarchy
Property
f is an ancestor of g (descendant)
Test Implication from descendant (g) to ancestor (f)
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
body → car, gas → car, . . .
SLIDE 37 Feature Hierarchy
Property
f is an ancestor of g (descendant)
Test Implication from descendant (g) to ancestor (f)
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
Direct links: transitive reduction
SLIDE 38
Mandatory Features
Property
g is a mandatory subfeature of f
Test Biimplication between variables corresponding to g and f
f → g
SLIDE 39 Mandatory Features
Property
g is a mandatory subfeature of f
Test Biimplication between variables corresponding to g and f
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
body → car, car → body, . . .
SLIDE 40 And Groups
Property
g is a mandatory subfeature of f
Test Biimplication between variables corresponding to g and f
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
And-groups: cliques in the graph
SLIDE 41
Or Groups
Recall that for an or-group:
φ → (f → f1 ∨ · · · ∨ fk)
But then also
φ → (f → f1 ∨ · · · ∨ fk ∨ g)
holds for g other than fi.
SLIDE 42 Or Groups
Implied disjunction can always be weakened! All implied disjunctions =
- versized and too-many or-groups
So detect minimal disjunctions
SLIDE 43 Or Groups
Implied disjunction can always be weakened! All implied disjunctions =
- versized and too-many or-groups
So detect minimal disjunctions
{fi}i=1..k is a prime implicant of f
(see the paper) Prime implicants are well studied in fault tolerance analysis
SLIDE 44 Or Groups
Property Or-groups of features rooted in f Test Find prime implicants of f
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
electric ∧ gas → engine
SLIDE 45 Or Groups
Property Or-groups of features rooted in f Test Find prime implicants of f
car power-locks keyless-entry gear engine body electric gas manual automatic keyless-entry→power-locks
manual ∧ electric ∧ gas → engine
SLIDE 46
Algorithm
1 if unstatisfiable then quit 2 remove & report dead features 3 compute implication graph & its transitive reduction 4 find and-groups by contracting cliques 5 find all or-groups and xor-groups candidates
SLIDE 47
Contents
Motivation Syntax & Semantics (going there) Algorithm (going back again) Concluding remarks
SLIDE 48
Discussion (I)
Constructs an overapproximation (add a leftover constraint) The graph constructed contains maximum information (complete)
SLIDE 49
Discussion (I)
Constructs an overapproximation (add a leftover constraint) The graph constructed contains maximum information (complete) Implemented using BDDs, algorithm by Coudert&Madre,1992 Efficient and scalable (computing prime implicants is the bottleneck)
SLIDE 50 Discussion (II)
Semantic operations on feature models become logical operations
Merge: (φFM1 → r) ∧ (φFM2 → r) Difference: φFM1 ∧ ¬φFM2 ...
SLIDE 51
Future Work
Generalize the kind of models extracted beyond FODA Implement complex refactorings using logical representations Experiment with extracting models from code
SLIDE 52
Summary
Successful exercise in semantics Exhibited links between logical & relational phenomena and FMs
implication graphs, transitive reduction, cliques, prime implicants
Effective extraction procedure Implemented Suggested ideas for future work