Before we discuss our synthesis algorithm, we must first define the problem that our algorithm is addressing. Given a set of features (F) and a propositional formula (ϕ), the feature model synthesis problem is defined as synthesizing a feature diagramFD such that the input formulaϕ entails the configuration semantics of the feature diagram. We now define the problem using the definition of a feature diagram (Definition2.1), whereFD= (F, E,(Em, Ei, Ex), (Go, Gx, Gm)):
Definition 5.1. The feature model synthesis problem (FMS) is defined as given a
consistent rooted formulaϕ over a set of feature F, synthesize a feature diagram
FDover F, such that ϕ → [[FD]], andFDis maximal such that (i) no element can be added to the set of mandatory edges (Em), implies edges (Ei), or excludes edges
(Ex), OR-, MUTEX-, and XOR-groups (Go, Gm, Gx) and (ii) no group can be moved
from Go∪ Gm to Gx without violatingϕ → [[FD]].
Note that our problem definition includes a condition such that the synthesized diagram is maximal. This condition is necessary to avoid synthesizing trivial models that are not useful in any synthesis scenario. For example, a feature diagram where all features are nested under the root is consistent with any rooted formula such as the one in Figure5.1b. The feature diagram in Figure5.1bis non-maximal with respect to the input in Figure5.1abecause it is missing anOR-group and implies edges fromDtoB
andC. In an automated synthesis algorithm, maximal feature diagrams are more useful, since they contain the maximal constraints that are allowed by the feature modeling notation.
Theorem 5.1. The decision version of FMS is NP-hard.
(B∨C∨D→A) ∧(D→B∧C) ∧(A→B∨C) (a) Input A B C D (b) A non-maximal feature diagram A B C D implies (c) A maximal feature diagram A B C D implies (d) Another maximal feature diagram A B C D
(e) Feature graph
formula ϕ over the set of features F, is a given feature diagram FDover F actually maximal such thatϕ → [[FD]]?
Iff the answer is yes, then for any two variables in F , there is no other binary implications entailed byϕ than those that are edges in D. If such implications did exist, then the model would not be maximal. Thus, for an implication x → y, we check if ψ ∧ x ∧ ¬ y is satisfiable (disproves x→ y) for an arbitrary consistent rooted formula ψ. Such a SAT check is NP-hard.
The proof reduces the decision version of FMS to checking satisfiability of a propositional formula or the equality of two propositional formulas—both NP-hard problems. Even with the concept of maximality, there could be more than one maximal feature diagram describing a given input. Figures 5.1c and 5.1d are two maximal feature diagrams. Figure5.1cis maximal since all possible feature groups and implies edges are present. In Figure5.1d, even thoughDcould be a child ofC, the diagram is still maximal since an implies edge takes the place of the hierarchy edge. The definition of maximality in Definition5.1does not require that each feature be as deeply nested as possible.
As we see from Figures 5.1c and 5.1d, there could still be more than one maximal feature diagram describing a given set of configurations or dependencies. We introduce the notion of a feature graph that encapsulates all maximal feature diagrams as a single structure, defined as:
Definition 5.2. A feature graph is a tupleFG(F, E, Ex,(Go, Gx, Gm)) whereF is a
set of features, E⊆F×F is a set of directed child-parent edges; Ex⊆2F is a set of
undirected excludes edges, for each e∈ Ex,|e| = 2; sets Go, Gx, Gm contain subsets
of E, participating in OR-groups,XOR-group andMUTEX-groups respectively. The
following constraints hold inFG:
1. (F, E) is a connected transitively reduced DAG,
2. All edges in a group share the same parent, so if g∈ Gi for i∈{o,x,m}
and(f1, f2), (f3, f4)∈ g then f2= f4,
3. E, Exare disjoint (i.e., no hierarchy edge is an exclude edge).
Compared to the definition of a feature diagram (Definition 2.1), a feature graph relaxes the constraints on the feature hierarchy such that a feature graph forms a DAG
instead of a tree, and feature groups can overlap. The definition of feature diagram allows feature groups with〈m, n〉 cardinality; however, we restrict the definition of a feature graph to onlyOR-〈0, n〉, XOR-〈1, n〉, andMUTEX-groups〈0, 1〉 since only these
cardinalities are supported by our synthesis algorithm. We also seen in our study of real world feature models (Chapter4) that most feature groups in practice were
XOR- or OR-groups. Compared to feature diagrams, implies edges are also missing
from a feature graph—these edges are represented as part of the(F, E) DAG. Finally, mandatory features are absent in a feature graph since mandatory features co-occur with their parent in all legal configurations. Mandatory features are represented as a single node (i.e., an AND-group) in the feature graph. Figure5.1eshows the feature
graph for the input in Figure5.1a.
Since feature graphs encapsulate all consistent maximal feature diagrams with respect to a set of input features and legal configurations, it provides a convenient target artifact for automated synthesis algorithms. We define the feature graph synthesis problem as:
Definition 5.3. The feature graph synthesis problem is defined as given a consistent
rooted formulaϕ over a set of featureF, synthesize a feature graphFGoverF, such thatϕ → [[FG]], and given aFG, (i) no element can be added to the set of child-parent edges (E), excludes edges (Ex), OR-, MUTEX-, and XOR-groups (Go,
Gm, Gx) and (ii) no group can be moved from Go∪ Gm to Gx, without violating
ϕ → [[FG]].
The problem definition assumes that the input is given as a set of dependencies or configurations expressed as a rooted formulaϕ over a set of features F. If a root is not present in the formula, a new variable r0and implications fi ∈F, fi → r0can be introduced toϕ. All possible implications from the input are also contained the DAG formed by the features and edges(F, E). Furthermore, all possible mandatory, implies,
excludes edges,OR-, XOR-, andMUTEX-groups XORare captured in the resulting feature
graph. Finally, the last condition is that the set ofXOR-groups is maximal.