30.08.2014 Views

url - Universität zu Lübeck

url - Universität zu Lübeck

url - Universität zu Lübeck

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.3. NP-COMPLETENESS FOR PATH EXPRESSIONS WITH NOT 135<br />

Now we build two path expressions p and p ′ corresponding to F A and F B as follows:<br />

Both p and p ′ have the same prefix, for instance /a. The formulas are attached<br />

as a qualifier to the a node. The logical operators ∧ and ∨ are translated to AND<br />

and OR operators from XPath. Each positive variable of F A respectively F B is interpreted<br />

as the existence of a matching child element. Each negative variable is<br />

covered by a NOT operator.<br />

Because F A and F B are always satisfiable individually Mod(p) and Mod(p ′ ) are<br />

not empty.<br />

If p(t) ∩ p ′ (t) ≠ ∅ it means that there is an a node that fulfills the two qualifiers of p<br />

and p ′ . But this means that F A and F B are satisfied simultaneously. Hereby, the<br />

reduction 3SAT ≤ pol XIP is finished; the conversion from a Boolean formula to a<br />

path expression can be done in polynomial (even linear) time.<br />

Finally, XIP NOT is in NP because a nondeterministic Turing-machine may guess a<br />

satisfying assignment if it exists. Because the XIP NOT is NP-hard and belongs to<br />

NP it is NP-complete.<br />

<br />

7.3.1 Algorithm and Complexity of XIP NOT<br />

Our algorithm solving XIP NOT for two path expressions p, p ′ ∈ XP {[],∗,//,NOT } is<br />

based on the introduced algorithm checking the intersection of linearized path<br />

expressions (see figure 7.3). If the linearized path expressions of p and p ′ have<br />

an intersection we now have to check if their additional qualifiers and keys are<br />

mutually exclusive. This implies that we have to check the satisfiability of p ∧ p ′ .<br />

Because of the NP-completeness of XIP NOT this step has an exponential worst<br />

case complexity: every permutation of true/false that is assigned to the variables<br />

in the qualifiers has to be generated and checked if it satisfies p ∧ p ′ . If we find<br />

no satisfying configuration the intersection remains empty.<br />

The algorithm uses a simple optimization step that reduces the number of variables<br />

that have to be checked: A variable may only be responsible for mutual<br />

exclusiveness if it appears negated and non-negated in the set of qualifiers of p<br />

and p ′ . Therefore, we can remove all variables from the expressions that are only<br />

negated or non-negated. This simple optimization has a similar aim as the Davis<br />

Putnam algorithm [23] for deciding 3SAT. The extended algorithm is presented in<br />

figure 7.4:<br />

In the first step the algorithm checks whether the linearized path expressions<br />

have an intersection. If this is not the case the algorithm stops and returns false.<br />

In lines 2 to 4 we reduce the numbers of relevant variables by removing the trivial<br />

ones. The function getNegVars returns all variables from a path expression<br />

that appear negated. The function getPosVars is defined vice versa. In step 5 the<br />

algorithm iterates over all possible true/false values for the remaining variables

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!