NP Completeness Ccoew 2022 PDF
NP Completeness Ccoew 2022 PDF
Abhijat Vichare
[email protected]
September 2022
Plan
The problem
Given a Boolean formula in CNF
(x ∨ y ) ∧ (¬y ∨ ¬z) ∧ (z ∨ x)
Find an assignment of values to variables that make it true
OR
Report that none exists.
Note
• 2Sat: Disjunction of two variables, e.g. (x ∨ y )
• 3Sat: Disjunction of three variables, e.g. (x ∨ y ∨ ¬z)
Some interesting problems
Sat, the Boolean satisfiability problem
Solution
Find independent vertices that are not directly connected, else fail.
Some interesting problems
Euler, the Königsberg bridges problem
Problem:
2D Pairing
Boy 2 Girl 2
Find a pairing such
that the likes relation- Boy 3 Girl 3
ship is satisfied
Boy 4 Girl 4
Some interesting problems
3D Match, or the triplet matching problem
3D Pairing
Boy 1 Girl 1
Boy 2 Girl 2
Boy 4 Girl 4
Pet 2
Pet 3
Some interesting problems
Shortest and Longest paths in a graph.
Background ideas
What does the Theory of Computation tell us?
Computability ≡ . . .
Background ideas
What does the Theory of Computation tell us?
Computability ≡ . . .
• . . . Mechanical Evaluation
Background ideas
What does the Theory of Computation tell us?
Computability ≡ . . .
• . . . Mechanical Evaluation
• Mechanical: A machine – “non-intelligent” – can do it
Machines view: Turing machines
• Evaluation: “Step-by-step” process to reach the result value
the Function view: λ calculus, Partial recursive functions
Background ideas
What does the Theory of Computation tell us?
Computability ≡ . . .
• . . . Mechanical Evaluation
• Mechanical: A machine – “non-intelligent” – can do it
Machines view: Turing machines
• Evaluation: “Step-by-step” process to reach the result value
the Function view: λ calculus, Partial recursive functions
• . . . Algorithm
Background ideas
What does the Theory of Computation tell us?
Computability ≡ . . .
• . . . Mechanical Evaluation
• Mechanical: A machine – “non-intelligent” – can do it
Machines view: Turing machines
• Evaluation: “Step-by-step” process to reach the result value
the Function view: λ calculus, Partial recursive functions
• . . . Algorithm
In essence:
Computation theory tells us what is an algorithm, if it exists!
Background ideas
Some terminology
A problem?
Background ideas
Some terminology
A problem?
Instance of a problem?
Background ideas
Some terminology
Instance of a problem?
4109837 + 8781239854
Background ideas
Some terminology
True
Background ideas
Some questions
True
Background ideas
Some questions
False
Background ideas
Some questions
False
Algorithm: Effective procedure to solve (yield a solution) a
class of problems
False
Algorithm: Effective procedure to solve (yield a solution) a
class of problems
Tip
Study the shapes of various functions!
Background ideas
What are Ω, O and Θ?
200
x2+2x+1
x2
150
y = x2 + 2x + 1, x2
100
50
0
0 1 2 3 4 5 6 7 8 9 10
x
Figure: Ω(x 2 )
Background ideas
What are Ω, O and Θ?
200
2x2
180 x2+2x+1
160
140
y = x2 + 2x + 1, x2
120
100
80
60
40
20
0
0 1 2 3 4 5 6 7 8 9 10
x
Figure: O(x 2 )
Background ideas
What are Ω, O and Θ?
200
2x2
x2+2x+12
x
150
y = x2 + 2x + 1, x2
100
50
0
0 1 2 3 4 5 6 7 8 9 10
x
Figure: Θ(x 2 )
What intuitively is “algorithm hardness”?
Second: classify
Use the O/Ω/Θ form to label an algorithm as
• logarthmic (O(logn)),
• polylogarithmic (O(nlogn)),
• linear (O(n)),
• polynomial (O(nk )),
• exponential (O(an ))
• etc.
and
Compare with other algorithms using plots of graphs earlier.
What intuitively is “algorithm hardness”?
Class P
• Set of functions computable in polynomial time on a DTM
• Has nice closure properties, i.e.
Combinations of polynomial time algorithms is also polynomial
Class NP
• Set of functions verifiable in polynomial time on a DTM
(They may be computable in polynomial time on a NDTM)
• Not much known, despite efforts
• A subset (proper or improper?) of problems reduce to each
other, and are called NP Complete
Key ideas in Complexity theory
What makes algorithms P class?
Questions!
• Does F always exist?
• What is the complexity of F ?
• Is this same as Turing reduction?
Key ideas in Complexity theory
Reduction: Examples
(a1 ∨ a2 ∨ a3 ∨ a4 ∨ a5 ∨ . . .)
Introduce new variables yi and rewrite as:
The idea
(P ∈ NP-Complete) ≡ (P ∈ NP) ∧ (∃Q ∈ NP : P reduces to Q)
Revisiting our problems
Note
• ∀A ∈ P: A finds solution in polynomial time.
• ∀A ∈ NP: A verifies solution in polynomial time.
Key ideas in Complexity theory
What we know and do not know