This compendium of P-complete problems asserts that unit resolution (section A.6.1 in the book) and context-free grammar parsing (A.7.1) are P-Complete. But it does not provide a direct reduction. What does the direct reduction from unit resolution to context-free grammar parsing look like?
1 Answers
Background
An instance of a unit resolution problem starts with a logical formula in conjunctive normal form, i.e. a bunch of OR clauses (like $(a \vee b \vee \neg c)$) joined together by ANDs.
Some formulas can be simplified. If we have a formula that contains a clause like $(a \vee b_1 \vee b_2 \vee b_3)$ and also the single-literal clause $\neg a$, we can delete both clauses and replace them with the shorter clause $(b_1 \vee b_2 \vee b_3)$ which is logically equivalent. This is called a unit resolution—"unit" because it requires a clause that has only one literal in it.
Given a logical formula in cnf, the UNIT question is: can you perform some sequence of unit resolutions that produces an empty clause, with all literals cancelled? For example, $(a \vee \neg b)\wedge(\neg a)\wedge (a \vee b)$ has this property. (Whenever you can do this, it indicates that the overall formula can't be satisfied.)
Reduction
We can reduce the problem of deciding UNIT to the problem of deciding whether a context free grammar accepts a given string, as follows.
The basic idea is that you can draw a single unit resolution as a little minimal binary tree with two clauses as the child nodes (one of the clauses must be a single literal) and the parent being their simplified combination. If you can derive the empty formula from a sequence of unit resolutions, this means it is possible to draw a binary tree whose root is the empty clause, whose leaves are clauses from the formula, and every binary branch point is a valid unit resolution. All we're going to do is design a context free grammar whose grammatical parse trees correspond to unit resolution derivation trees like this.
Given an instance of the UNIT problem (a formula written in cnf), build a CFG out of it as follows—
- Take each clause and assign it a unique non-terminal symbol. For each such clause $A_i$, add the rule $A_i \mapsto \epsilon$. These will be the only terminal-producing rules in the grammar, so they'll enforce the rule "every leaf of the tree must be a clause that was originally in the original formula"
- Take each subclause and assign it a unique non-terminal symbol. For example, $(a \vee b \vee \neg c)$ has seven subclauses $(a \vee b)$, $(a \vee \neg c)$, $(b \vee \neg c)$, $(a),(b),(\neg c), $ and ().
- Now we turn every valid unit reduction into a legal production rule. Look at all pairs of sub/clauses. Whenever $X$ is a sub/clause and $Y$ is a sub/clause, and Y has only one literal, and X contains the opposite of that literal, then we know they can be unit resolved to Z = (X with that literal removed). Add the rule $Z\mapsto XY$ to the grammar.
- Declare the empty clause symbol to be the start symbol of this grammar (the root of all the parse trees)
The only string this grammar can possibly accept is the empty string. It accepts the empty string if and only if there is a sequence of valid unit derivations starting from full clauses in the original formula, and eventually producing the empty formula.
When a formula in cnf isn't in UNIT and can't produce the empty formula, what happens is none of the parse trees generated by this grammar can ever terminate; they all loop forever without being able to bottom out in original clauses.
- 19,274