First NP-complete Problem
•This is shown by considering any computable algorithm can be represented by a logical circuit that can be encoded into a state machine on a general purpose computer.
•The operation of the algorithm simply transitions between states in the computer. At some point, one of the bits in the computer will represent the output of the algorithm and thus any algorithm can be reduced to a circuit Satisfiability problem (in polynomial time).
•Problem
A Boolean expression is a formula composed of
1.n Boolean variables x1, x2, ..., xn
2.m Boolean operations consisting of ∧ (logical AND), ∨ (logical OR), ¬ (logical NOT), → (logical implication), and ⇔ (logical if and only if)
3.Parentheses
–Parentheses delineate clauses that consist of a group of variables that are connected by operands.
•Can we assign 0’s and 1’s to the variables so that Boolean expression is 1.
•SAT = {(Φ) : Φ is a Satisfiable Boolean formula }
•Example:
((x1 ®x2) Ú Ø((Øx1 « x3) Ú x4)) ÙØx2
• Has Satisfying assignment {x1 = 0, x2 = 0, x3 = 1, x4 = 1}, since
Φ = ((0 ®0) Ú Ø((Ø0 « 1) Ú 1)) ÙØ0
= (1 Ú Ø((1« 1) Ú 1))
= 1
• Thus formula Φ belongs to SAT.
•
•SAT belongs to NP
–Given a satisfying assignment, the verification algorithm replaces each variable with its value and evaluates the formula, in polynomial time.
•SAT is NP-Hard (Show CIRCUIT-SAT £p SAT).
•CIRCUIT-SAT £p SAT i.e. , any instance of circuit Satisfiability can be reduced in polynomial time to an instance of formula Satisfiability .
–Look at the gate that produces the circuit output.
–Inductively express each of gates inputs as formulas.
–Formula for the circuit is then obtained by writing an expression that applies the gate’ function to its input formulas.
x10 = ( x7 Ù x8 Ù x9)
= ( x1 Ù x2 Ù x4) Ù (x5 Ú x6) Ù (x6 Ú x7)
is given by x4 ⇔ ( x1 ∧ x2 ∧ x3 ).
= x10 Ù (x5 « (x1 Ú x2))
= x10 Ù (x6« Øx4)
= x10 Ù (x7 «( x1 Ù x2 Ù x4))
= x10 Ù (x8 « (x5 Ú x6))
= x10 Ù (x9 « (x6 Ú x7))
= x10 Ù (x10 « ( x7 Ù x8 Ù x9))
SAT £p 3-CNF-SAT to prove NPC.
Proof
Step 1: Convert clauses into a binary parse tree.
–Since each Boolean operator is a binary operator, we simply construct a binary parse tree where the nodes are the operators and the literals are leaves.
–In the case of clauses with multiple literals, we simply add associative parentheses as needed to make binary clauses.
–We then construct a new expression, similarly to the above reduction from circuit Satisfiability to Boolean Satisfiability, by AND'ing the clauses representing each node with the final output.
• Step 2: Convert each clause into CNF form.
–We then construct a truth table for each clause (which contains at most 3 literals) and use the sum-of-products method to create an equivalent Boolean expression that evaluates to 0 in which we have a set of AND'ed clauses that consist of OR'ed literals (this is known as DNF form - disjunctive normal form).
Finally we add auxiliary variables p and q as needed to clauses that have less than 3 literals as follows:
–If the clause contains 3 literals, then keep it as is
–If the clause contains 2 literals, then create two AND'ed clauses that contain p and ¬ p. In other words, for the clause ( xi ∨ xj ) replace it with
–
( xi ∨ xj ∨ p ) ∧ ( xi ∨ xj ∨ ¬ p )
Since for any assignment of p, one of the clauses will evaluate to the original and the other will evaluate to 1 (thus not changing the final result of the original expression).
–If the clause contains 1 literal, then create four AND'ed clauses that contain p and ¬ p and q and ¬ q. In other words, for the clause ( xi ) replace it with
( xi ∨ p ∨ q ) ∧ ( xi ∨ ¬ p ∨ q ) ∧ ( xi ∨ p ∨ ¬ q ) ∧ ( xi ∨ ¬ p ∨ ¬ q )
•Again since any assignment of p and q will make one of the clauses evaluate to the original and all the others evaluate to 1.
•
•This procedure can be done in polynomial time since the first step adds at most one variable and one clause per operator in the original expression, the second step adds at most 8 clauses (since for 3 literals the truth table has 8 rows), and the third step adds at most 4 clauses.
Consider the Boolean expression
φ = (( x1 → x2 ) ∨ ¬ (( ¬ x1 ⇔ x3 ) ∨ x4 )) ∧ ¬ x2
–Step 1: Draw binary parse tree
Parse the expression by creating the following output variables of sub expressions:
y6 = ( ¬ x1 ⇔ x3 )
y5 = ( y6 ∨ x4 )
y4 = ( ¬ y5 )
y3 = ( x1 → x2 )
y2 = ( y3 ∨ y4 )
y1 = ( y2 ∧ ¬ x2 )
φ' = y1 ∧ ( y1 ⇔ ( y2 ∧ ¬ x2 ))
∧ ( y2 ⇔ ( y3 ∨ y4 ))
∧ ( y3 ⇔ ( x1 → x2 ))
∧ ( y4 ⇔ ( ¬ y5 ))
∧ ( y5 ⇔ ( y6 ∨ x4 ))
¬ φ'1 = ( ¬ y1 ∧ y2 ∧ ¬ x2) ∨ ( y1 ∧ ¬ y2 ∧ ¬ x2) ∨ ( y1 ∧ ¬ y2 ∧ x2) ∨ ( y1 ∧ y2 ∧ x2)
φ"1 = ( y1 ∨ ¬ y2 ∨ x2) ∧ ( ¬ y1 ∨ y2 ∨ x2) ∧ ( ¬ y1 ∨ y2 ∨ ¬ x2) ∧ ( ¬ y1 ∨ ¬ y2 ∨ ¬ x2)
¬ φ'4 = ( ¬ y4 ∧ ¬ y5 ) ∨ ( y4 ∧ y5 )
φ"4 = ( y4 ∨ y5 ) ∧ ( ¬ y4 ∨ ¬ y5 )
φ"'4 = ( y4 ∨ y5 ∨ p ) ∧ ( y4 ∨ y5 ∨ ¬ p ) ∧ ( ¬ y4 ∨ ¬ y5 ∨ p ) ∧ (¬ y4 ∨ ¬ y5 ∨ ¬ p )
φ"'0 = ( y1 ∨ p ∨ q ) ∧ ( y1 ∨ ¬ p ∨ q ) ∧ ( y1 ∨ p ∨ ¬ q ) ∧ ( y1 ∨ ¬ p ∨ ¬ q )
CLIQUE
–The proof of the reduction from 3-CNF to clique is very interesting because it takes a Boolean expression and converts it into an equivalent graph even though the problems seem to stem from different mathematical domains.
–Again the proof is constructive. Assume that the 3-CNF expression has k clauses. We then construct a graph such that if the 3-CNF expression is satisfiable, then there will be a clique on the graph of size k.
•
•Step 1: Add vertices to the graph
–For each clause, add a vertices in the graph for each literal or negated literal (since each clause has exactly 3 literals there will be 3 vertices per clause in the graph giving a total of 3k vertices in the final graph).
•Step 2: Add edges between vertices
–Add edges between vertices under the following conditions
§The two vertices come from different clauses
§The vertices are not negations of each other
–Using this procedure, it can be shown that if there is an assignment of literals for the 3-CNF formula then those literals will produce a clique of size k.
–Since at least one literal (or its negation) must be assigned 1 in the expression, these vertices will form a clique in the graph.
–Conversely, if there is a clique of size k then the clique will contain the literals that satisfy the 3-CNF formula.
–Since there are no edges between vertices from the same clause, assigning the vertices in the clique to 1 will give a satisfying assignment.
•Example
–Consider the following 3-CNF expression
φ = ( x1 ∨ ¬ x2 ∨ ¬ x3 ) ∧ ( ¬ x1 ∨ x2 ∨ x3 ) ∧ ( x1 ∨ x2 ∨ x3 )