'. '

# LibraryReExportIsNPComplete

(Difference between revisions)
 Revision as of 10:24, 25 May 2008 (edit) (→Converstion of wikipedia::3SAT to Module Dependencies Problem)← Previous diff Revision as of 10:34, 25 May 2008 (edit) (undo) (→wikipedia::3SAT)Next diff → Line 4: Line 4: The problem of satisfying a logic formula remains '''NP'''-complete even if all expressions are written in ''[[wikipedia::conjunctive normal form]]'' with 3 variables per clause (3-CNF), yielding the '''3SAT''' problem. This means the expression has the form: The problem of satisfying a logic formula remains '''NP'''-complete even if all expressions are written in ''[[wikipedia::conjunctive normal form]]'' with 3 variables per clause (3-CNF), yielding the '''3SAT''' problem. This means the expression has the form: - :$(x_{11} \wedge x_{12} \wedge x_{13}) \vee$ + :$(x_{11} \vee x_{12} \vee x_{13}) \wedge$ - :$(x_{21} \wedge x_{22} \wedge x_{23}) \vee$ + :$(x_{21} \vee x_{22} \vee x_{23}) \wedge$ - :$(x_{31} \wedge x_{32} \wedge x_{33}) \vee$ + :$(x_{31} \vee x_{32} \vee x_{33}) \wedge$ :$...$ :$...$ - :$(x_{n1} \wedge x_{n2} \wedge x_{n3})$ + :$(x_{n1} \vee x_{n2} \vee x_{n3})$ where each $x_{ab}$ is a variable $v_i$ or a negation of a variable $\neg v_i$. Each variable $v_i$ can appear multiple times in the expression. where each $x_{ab}$ is a variable $v_i$ or a negation of a variable $\neg v_i$. Each variable $v_i$ can appear multiple times in the expression.

## Revision as of 10:34, 25 May 2008

This page describes a way to convert any wikipedia::3SAT problem to a solution of finding the right configuration from conflicting libraries in a system that can re-export APIs. Thus proving that the later problem is wikipedia::NP-complete.

## wikipedia::3SAT

The problem of satisfying a logic formula remains NP-complete even if all expressions are written in wikipedia::conjunctive normal form with 3 variables per clause (3-CNF), yielding the 3SAT problem. This means the expression has the form:

$(x_{11} \vee x_{12} \vee x_{13}) \wedge$
$(x_{21} \vee x_{22} \vee x_{23}) \wedge$
$(x_{31} \vee x_{32} \vee x_{33}) \wedge$
...
$(x_{n1} \vee x_{n2} \vee x_{n3})$

where each xab is a variable vi or a negation of a variable $\neg v_i$. Each variable vi can appear multiple times in the expression.

## Module Dependencies Problem

Let A,B,C,... denote an API.

Let A1,A1.1,A1.7,A1.11 denote compatible versions of API A.

Let A1,A2.0,A3.1 denote incompatible versions of API A.

Let Ax.y > Bu.v denote the fact that version x.y of API A depends on version u.v of API B.

Let $A_{x.y} \gg B_{u.v}$ denote the fact that version x.y of API A depends on version u.v of API B and that B re-exports its elements.

Let Repository R = (M,D) be any set of modules with their various versions and their dependencies on other modules with or without re-export.

Let C be a Configuration in a repository R = (M,D), if $C \subseteq M$, where following is satisfied:

$\forall A_{x.y} \in C, \forall A_{x.y} \gg B_{u.v} \in D \Rightarrow \exists w >= v \wedge B_{u.w} \in C$ - each re-exported dependency is satisfied with some compatible version
$\forall A_{x.y} \in C, \forall A_{x.y} > B_{u.v} \in D \Rightarrow \exists w >= v B_{u.w} \in C$ - each dependency is satisfied with some compatible version
Let there be two chains of re-exported dependencies $A_{p.q} \gg ... \gg B_{x.y}$ and $A_{p.q} \gg ... \gg B_{u.v}$ then $x = u \wedge y = v$ - this guarantees that each class has just one, exact meaning for each importer

Module Dependency Problem: Let there be a repository R = (M,D) and a module $A \in M$. Does there exist a configuration C in the repository R, such that the module $A \in C$, e.g. the module can be enabled?

## Converstion of wikipedia::3SAT to Module Dependencies Problem

Let there be wikipedia::3SAT formula with with variables v1,...,vm as defined above.

Let's create a repository of modules R. For each variable vi let's create two modules $M^i_{1.0}$ and $M^i_{2.0}$, which are mutually incompatible and put them into repository R.

For each formula $(x_{i1} \wedge x_{i2} \wedge x_{i3})$ let's create a module Fi that will have three compatible versions. Each of them will depend on one variable's module. In case the variable is used with negation, it will depend on version 2.0, otherwise on version 1.0. So for the formula

$v_a \vee \neg v_b \vee \neg v_c$

we will get:

$F^i_{1.1} \gg M^a_{1.0}$
$F^i_{1.2} \gg M^b_{2.0}$
$F^i_{1.3} \gg M^c_{2.0}$

All these modules and dependencies add into repository R

Now we will create a module T1.0 that depends all formulas:

$T_{1.0} \gg F^1_{1.0}$
$T_{1.0} \gg F^2_{1.0}$

...

$T_{1.0} \gg F^n_{1.0}$

and this module as well as its dependencies into repository R.

Claim: There $\exists$ a configuration C of repository R and $T_{1.0} \in C$ $\Longleftrightarrow$ there is a solution to the wikipedia::3SAT formula.