Formal Languages, Automata and Computability
Formal Languages, Automata and Computability
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
NP =
NTIME(n )
k
kN
P = NP?
If P = NP
Mathematicians would be out of a job
Cryptography as we know it would
not be possible (e.g. RSA)
AI program become perfect as
exhaustive search is efficient
If P = NP
Generation is as easy as recognition:
Being a chef is as easy as eating.
Writing symphonies is as easy as
listening to them.
Writing Shakespeare is as easy as
recognizing Shakespeare.
POLY-TIME REDUCIBILITY
A language A is polynomial time reducible to
language B, written A P B, if there is a
polynomial time computable function
f : * *, where for every w,
w A f(w) B
f is called a polynomial time reduction of A to B
NP Complete Problem:
hardest problem in NP
Intuitively, L is harder than L if L is
polynomial reducible to L.
NP Complete Problem: If such a problem
has an efficient algorithm (in P), then every
other problem also has efficient algorithm.
NP
SAT
NP-Complete Problems
3SAT
k-Clique
Vertex Cover
Independent Set
3SAT
Problem: Given a CNF where each clause
has 3 variables, decide whether it is
satisfiable or not.
(x1 x1 x2) (x1 x2 x2) (x1
x2 x2)
3SAT is NP Complete
3SAT = { | y such that y is a satisfying
assigment to and is in 3cnf }
NP
SAT
How to prove?
1. We can convert (in polynomial time) a
given SAT instance S into a 3SAT
instance S such that
Key Observation
x1 x2 x3 x4 x5 is satisfiable
if and only if
(x1 x2 z1) ( z1 x3 z2 )
( z2 x4 z3) ( z3 x4 x5)
is satisfiable.
Clauses in 3SAT
x 1 x1 x1
x1 x1 x2
x 1 x2 x3
x 1 x2 x3 x4
x 1 x2 x3 x4 x 5
CLIQUE
a
K-Cliques
A K-clique is a set of K nodes with all K(K1)/2 possible edges between them
CLIQUE is NP-Complete
NP
3SAT
CLIQUE
3SAT P CLIQUE
We transform a 3-cnf formula into (G,k) such that
3SAT (G,k) CLIQUE
The transformation can be done in time
that is polynomial in the length of
3SAT P CLIQUE
We transform a 3-cnf formula into (G,k) such that
3SAT (G,k) CLIQUE
If has m clauses, we create a graph with m
clusters of 3 nodes each, and set k=m
Each cluster corresponds to a clause.
Each node in a cluster is labeled with a literal
from the clause.
We do not connect any nodes in the same cluster
We connect nodes in different clusters whenever
they are not contradictory
c
l
a
u
s
e
x2
x2
x1
x1
x1
x2
x2
x2
k = #clauses
x1
x2
x1
x2
x1
x2
x1
x2
x2
x2
x1
Independent Set
An independent set is a set of nodes with no
edges between them
This graph
contains an
independent
set of size 3
Independent Set
G(V,E)
Complement of G
Given a graph G, let G*, the complement of G, be
the graph such that
two nodes are connected in G* if and only if the
corresponding nodes are not connected in G
G*
Key Observation
For a graph G, vertex set S is an
independent set if and only if S is clique in
G*.
Is there size k
independent
set in G*?
VERTEX COVER
a
a
d
c
c
e
b
Key Observation
For a graph G(V,E), S is a independent set if
and only if V-S is a vertex cover.
Other Problems in NP
Graph Isomorphism
Factoring Number
We dont know if they are NP Complete or
not.