Professional Documents
Culture Documents
Intractable Problems
(Smiley Puzzles and
Curing Cancer)
David Evans
http://www.cs.virginia.edu/evans
Complexity Classes
Class P: problems that can be solved in
polynomial time by a deterministic TM.
O (nk) for some constant k.
Easy problems like simulating the universe are
all in P.
Class NP: problems that can be solved in
polynomial time by a nondeterministic TM
Hard problems like the pegboard puzzle
sorting are in NP (as well as all problems in P).
21 April 2004
Problem Classes
Undecidable
NP
P
Decidable
Halting Problem: ()
Sorting: (n log n)
21 April 2004
P = NP?
Is there a polynomial-time solution to the
hardest problems in NP?
No one knows the answer!
The most famous unsolved problem in
computer science and math
Listed first on Millennium Prize Problems
win $1M if you can solve it
(also an automatic A+ in this course)
21 April 2004
If P NP:
Undecidable
NP
P
Decidable
Halting Problem: ()
Sorting: (n log n)
21 April 2004
If P = NP:
Undecidable
NP
P
Decidable
Halting Problem: ()
Sorting: (n log n)
21 April 2004
Smileys Problem
Input: n square tiles
Output: Arrangement of the
tiles in a square, where the
colors and shapes match up,
or no, its impossible.
21 April 2004
Lower bound: ()
(n)
Must at least look at every tile
Tight bound: ()
No one knows!
21 April 2004
10
NP Problems
Can be solved by just trying all possible
answers until we find one that is right
Easy to quickly check if an answer is right
Checking an answer is in P
11
21 April 2004
12
time
since
Big
Bang
n!
1E+26
2n
1E+24
1E+22
1E+20
1E+18
1E+16
1E+14
1E+12
2032
1E+10
1E+08
today
1E+06
n2
n log n
10000
100
1
2
21 April 2004
16
32
64
128
log-log scale
13
3
21 April 2004
14
3SAT Smiley
21 April 2004
Step 1: Transform
into smileys
Step 2: Solve (using
our fast smiley
puzzle solving
procedure)
Step 3: Invert
transform (back into
3SAT problem
15
21 April 2004
16
Propositional Grammar
Sentence ::= Clause
Sentence Rule: Evaluates to value of Clause
21 April 2004
17
Propositional Grammar
Clause ::= Clause
Not Rule: Evaluates to the opposite value
of clause (true false)
18
Proposition
Example
(or)
(and)
(not)
a (b c) b c
21 April 2004
19
20
SAT Example
(or)
(and)
(not)
SAT (a (b c) b c)
{ a: true, b: false, c: true }
{ a: true, b: true, c: false }
SAT (a a)
no way
21 April 2004
21
22
3SAT / SAT
Is 3SAT easier or harder than SAT?
It is definitely not harder than
SAT, since all 3SAT problems
are also SAT problems. Some
SAT problems are not 3SAT
problems.
21 April 2004
23
3SAT Example
(or)
(and)
(not)
3SAT ( (a b c)
(a b d)
(a b d)
(b c d ) )
{ a: true, b: false, c: false, d: false}
21 April 2004
24
3SAT Smiley
Like 3/stone/apple/tower puzzle, we
can convert every 3SAT problem into
a Smiley Puzzle problem!
Transformation is more complicated,
but still polynomial time.
So, if we have a fast (P) solution to
Smiley Puzzle, we have a fast
solution to 3SAT also!
21 April 2004
25
NP Complete
Cook and Levin proved that 3SAT was
NP-Complete (1971)
A problem is NP-complete if it is as hard
as the hardest problem in NP
If 3SAT can be transformed into a different
problem in polynomial time, than that
problem must also be NP-complete.
Either all NP-complete problems are
tractable (in P) or none of them are!
21 April 2004
26
NP-Complete Problems
Easy way to solve by trying all possible guesses
If given the yes answer, quick (in P) way to check
if it is right
Solution to puzzle (see if it looks right)
Assignments of values to names (evaluate logical
proposition in linear time)
27
28
29
Pegboard Problem
- Input: a configuration of n pegs on a
cracker barrel style pegboard
- Output: if there is a sequence of jumps
that leaves a single peg, output that
sequence of jumps. Otherwise, output
false.
If given the sequence of jumps, easy (O(n))
to check it is correct. If not, hard to know if
Proof that variant of this
there is a solution.
problem is NP-Complete is
attached to todays notes.
21 April 2004
30
31
Caffeine
If given a sequence, easy (not really) to
check if sequence has the right shape.
Note: US Drug sales = $200B/year
21 April 2004
32
Is it ever useful to be
confident that a problem is
hard?
21 April 2004
33