An alphabet, Σ is a finite collection of characters.
We will focus on Σ={0,1}, but it can be other things.
A language L over Σ is the collection of strings from this alphabet
Again, we will worry about ∅ ∪ {0,1,00,01,10,11,000, ...}
There are various operations on languages, but that is for another class (or three)
An algorithm A accepts a string x∈ L if A(x)=1, or rejects if A(x) = 0
An algorithm A accepts the language L={x∈{0,1}* | A(x) = 1}
But there can be strings x ∉ L such that A(x)= 1
An algorithm A decides the language L if for all x ∈ L, A(x) = 1 and all x ∉ L, A(x) = 0
A decides L in polynomial time if there is a constant k, such that for an y n length string x, the algorithm decides if x ∈ L in O(nk)
We will use the language concept to represent how we encode input to an algorithm.
and to represent a certificate (an answer we might want to check).
Problems and Encoding
SHORTEST-PATH is a a problem which takes a graph and two vertexes, and produces the shortest path between those vertexes.
PATH is the associated decision problem which takes a graph, two vertexes, and a cost, and outputs 1 if the shortest path between the two vertexes is at most the cost.
Let G be an encoded graph
PATH(G={V,E},u,v,k)
Verify that G is a directed graph, if not, return 0
Verify that u∈ V, v∈ V, if not, return 0
Use BFS to find a path P from u to v.
If |P| ≤ k
return 1
else
return 0
In this case, P is a certificate.
An algorithm to verify PATH would check to see if P is a path from u to v, and that it has cost less than or equal to k.
And can be done in polynomial time (trace the path, add up the costs)
HAM-CYCLE(G={V,E}) takes a graph G and returns 1 if it has a hamiltonian cycle (visits all vertexes except the first exactly once) or 0 if it does not.
There is no known polynomial time algorithm to accomplish this.
However, given a cycle C on a graph G, can we check to see if it is a hamiltonian cycle in O(nk) time? How?
Reducibility
A language L1 can be reduced in polynomial time to a language L2 (L1 ≤PL2) if
There exists f:{0,1}* → {0,1}* such that
x ∈ L1 if and only if f(x) ∈ L2
and f is computable in polynomial time.
The Class NP-Complete (NPC)
A language L is in class NP-complete if
L ∈ NP
L' ≤P L for every L' ∈ NP
Circuit Satifiability
CIRCUIT-SAT
Given a circuit constructed of and, or and not gates, is there any input for which the circuit will produce a 1?
I can not prove to you that this is hard, (If I could I would not be here, why?)
I can not prove that it is easy either.
I can, however (sort of) show that it is probably hard.
Brute force: for n inputs, there are 2n possible combinations. So trying all of them is just out.
Step 1, Is CIRCUIT-SAT ∈ NP?
For any given certificate, simply evaluate the circuit, if it produces a 1, then the certificate is valid, if not the certificate is not valid.
Can this be done in O(nk)?
Therefore CIRCUIT-SAT ∈ NP.
Now reduce all problems in NP to CIRCUIT-SAT.
Since any problem L ∈ NP it must have an algorithm A which verifies L in polynomial time.
Let M be an circuit which implements computer hardware.
The input to M is a single step (instruction) along with all storage (registers, memory)
The output of M is all storage
The algorithm A is stored in memory, along with the certificate.
Let T(n) be the worst case running time for A on a certificate of length n. (But this is polynomial)
So this circuit can be constructed in polynomial time.
In the end, A will produce either a 0 or a 1 (it is a verification algorithm)
So the constructed circuit will produce a 1 in some memory location only if the certificate is valid. Let this be the output of the circuit.
So if this circuit is satisfiable, then there is some input which will cause the circuit to produce a 1.