From Languages to Functions
Encoding a Computational Problem
A mathematical problem is first encoded as a binary string. If an instance \(I\) is encoded as \(\operatorname{enc}(I) \in \{0,1\}^*\), then the problem itself can be viewed as a function
whose input is the encoding of an instance and whose output is the required answer.
Decision problems are the special case where the output is just one bit. Then \(F_{\Pi}\) is a Boolean function.
What It Means for a TM to Compute an Arbitrary Function
Let \(f : \{0,1\}^* \to \{0,1\}^*\). A Turing machine \(M\) computes \(f\) if for every input \(x \in \{0,1\}^*\):
- \(M\) starts with \(x\) written on its input tape.
- \(M\) halts after finitely many steps.
- At halting, the designated output tape contains exactly \(f(x)\).
When \(f\) has range \(\{0,1\}\), the machine is solving a yes/no problem.
Example: Palindrome as a Boolean Function
Define the Boolean function
This is the function version of the language
So a language \(L\) and its characteristic function \(\chi_L\) carry the same information:
Why Revisit Problems as Functions?
- Decision problems become Boolean functions \(f:\{0,1\}^* \to \{0,1\}\).
- Search problems and optimization problems naturally need outputs in \(\{0,1\}^*\), not just one bit.
- Complexity theory often states classes using languages, but the function viewpoint helps us talk about output and simulation directly.
Remark: Common Set Notation
| Notation | Meaning |
|---|---|
| \(\mathbb{N}\), \(\mathbb{Z}\) | Natural numbers and integers |
| \([n]\) | \(\{1,2,\dots,n\}\) |
| \(A \subseteq B\), \(A \subsetneq B\) | \(A\) is a subset, or a proper subset, of \(B\) |
| \(|A|\) | Cardinality of the set \(A\) |
| \(A \cup B\), \(A \cap B\) | Union and intersection |
| \(A \setminus B\) | Elements of \(A\) not in \(B\) |
| \(A \times B\) | Cartesian product |
| \(\varnothing\), \(2^A\) | Empty set and power set |
| \(\Sigma^*\), \(\Sigma^{\le n}\) | All strings over \(\Sigma\), and all strings of length at most \(n\) |
Certificates and Verifiers
Mathematical Definition of a Certificate
Let \(f : \{0,1\}^* \to \{0,1\}\) be a decision problem. A certificate system for \(f\) consists of:
- a polynomial \(p\), and
- a verifier \(V : \{0,1\}^* \times \{0,1\}^* \to \{0,1\}\)
such that for every input \(x\),
Any string \(y\) satisfying this condition for a particular yes-instance \(x\) is called a certificate (or witness) for \(x\).
Interpretation
- The instance \(x\) is the question.
- The certificate \(y\) is the proposed proof.
- The verifier \(V\) checks the proof quickly.
- No certificate is required when \(f(x)=0\); all certificates must fail in that case.
Example Certificates
| Problem | Certificate | Verifier Check |
|---|---|---|
| \(\operatorname{3SAT}(\varphi)\) | An assignment \(a \in \{0,1\}^m\) | Evaluate \(\varphi(a)\) and accept iff every clause is satisfied |
| \(\operatorname{INDSET}(G,k)\) | A list of \(k\) vertices | Check all chosen vertices are distinct and no chosen pair forms an edge |
| \(\operatorname{PAL}(x)\) | No helpful certificate is needed | The verifier can check directly in polynomial time |
Verifier View of NP
The class \(NP\) can be described in terms of polynomial-size certificates:
where \(V\) is a deterministic polynomial-time algorithm. This is equivalent to the nondeterministic definition of \(NP\).
Alphabet Reduction and Binary Simulation
Time-Constructible Functions
A function \(T : \mathbb{N} \to \mathbb{N}\) is time-constructible if there is a Turing machine that, on input \(1^n\), writes \(1^{T(n)}\) and halts in \(O(T(n))\) time.
This condition lets a simulator budget its work in a controlled way.
Binary Alphabet Simulation Theorem
For every \(f : \{0,1\}^* \to \{0,1\}\) and time-constructible \(T : \mathbb{N} \to \mathbb{N}\), if \(f\) is computable in time \(T(n)\) by a Turing machine \(M\) using alphabet \(\Gamma\), then \(f\) is computable in time \(4 \log |\Gamma| \, T(n)\) by a Turing machine \(\widetilde{M}\) using the alphabet \(\{0,1,\sqcup,B\}\).
Here \(\sqcup\) is the blank symbol and \(B\) is used as a block marker.
Idea of the Simulation
Choose a fixed-length binary encoding for each symbol of \(\Gamma\). Let \(\ell=\lceil \log |\Gamma| \rceil\).
Represent one tape cell of \(M\) by a block \(B\,b_1b_2\dots b_{\ell}\) on \(\widetilde{M}\).
To simulate one transition, decode the current block, compute the next move, rewrite the block, and move to the adjacent block.
One simulated step costs \(O(\ell)\) time, giving total time \(O(\log |\Gamma| \cdot T(n))\).
Precision About the Constant
The lecture statement writes \(4 \log |\Gamma| \, T(n)\). A precise block-length argument often gives \(4 \lceil \log |\Gamma| \rceil T(n)\). The important message is that changing from any finite alphabet to a binary-style alphabet costs only a constant-factor slowdown.
Oblivious TMs and DTIME
Oblivious Turing Machine
A multi-tape Turing machine is oblivious if the head position on each tape depends only on the input length and the time step, not on the actual contents of the input.
for some fixed function \(h_i\), where \(n=|x|\).
So the movement schedule is predetermined; only the symbols written and the branch decisions depend on the input.
Why Obliviousness Matters
- It separates where the head goes from what data is stored there.
- It is useful in uniform circuit constructions and simulation theorems.
- Obliviousness does not change what is computable; it only changes the schedule of the computation.
Definition of \(DTIME(T(n))\)
In the Boolean-function viewpoint,
For languages, the equivalent definition is
Matching Language and Function Viewpoints
The language view and the Boolean-function view agree perfectly for decision problems. We simply move between \(L\) and \(\chi_L\).
Decision problem = Boolean function = language characteristic function.
Defining P and NP
Arora-Barak Style Definitions
Using standard complexity-class notation,
Here
How the Two Classes Differ
- \(P\): deterministic polynomial-time solvability.
- \(NP\): nondeterministic polynomial-time solvability, or equivalently, polynomial-time verifiability.
- \(P \subseteq NP\) because a deterministic machine is a special case of a nondeterministic one.
Examples to Keep in Mind
- \(\operatorname{PAL} \in P\): compare the string with its reverse using a polynomial-time algorithm.
- \(\operatorname{3SAT} \in NP\): a satisfying assignment is a polynomial-size certificate.
- \(\operatorname{INDSET} \in NP\): a chosen vertex set is a polynomial-size certificate.
Verifier Form of NP
A language \(L\) is in \(NP\) iff there exist a polynomial \(p\) and a deterministic polynomial-time verifier \(V\) such that
This is exactly the certificate definition from the previous tab.
Detailed Reduction: \(\operatorname{3SAT} \le_p \operatorname{INDSET}\)
The Two Problems
We reduce a formula \(\varphi\) with clauses \(C_1,\dots,C_m\) to a graph \(G_{\varphi}\) and choose \(k=m\).
Construction of \(G_{\varphi}\)
Suppose each clause has the form
- Create one vertex \(v_{ij}\) for each literal occurrence \(\ell_{ij}\). So the graph has \(3m\) vertices.
- Within each clause \(C_i\), connect the three vertices \(v_{i1},v_{i2},v_{i3}\) to form a triangle.
- If two vertices correspond to contradictory literals, such as \(x\) and \(\neg x\), connect them by an edge even if they belong to different clauses.
- Set \(k=m\).
Why the Reduction Works
| If \(\varphi\) is satisfiable | If \(G_{\varphi}\) has an independent set of size \(m\) |
|---|---|
Choose one true literal from each clause. This gives \(m\) vertices, one per triangle. Two chosen
vertices cannot be adjacent:
|
Any independent set can contain at most one vertex from each clause triangle. Since there are \(m\) clauses and the set has size \(m\), it must contain exactly one vertex from each clause. Because no two chosen vertices are joined by contradiction edges, the chosen literals are mutually consistent. Assign them all to be true, extend the remaining variables arbitrarily, and every clause is satisfied. |
Polynomial-Time Bound
The graph has \(3m\) vertices. Adding all clause edges and contradiction edges can be done by checking pairs of literal occurrences, so the reduction runs in polynomial time in \(|\varphi|\).
Therefore \(\operatorname{3SAT} \le_p \operatorname{INDSET}\).
Worked Example
Take
Then \(G_{\varphi}\) has three triangles:
- \(T_1 = \{x_1,\neg x_2,x_3\}\)
- \(T_2 = \{\neg x_1,x_2,x_4\}\)
- \(T_3 = \{\neg x_3,\neg x_4,x_2\}\)
Add contradiction edges between \(x_1\) and \(\neg x_1\), between \(\neg x_2\) and each occurrence of \(x_2\), between \(x_3\) and \(\neg x_3\), and between \(x_4\) and \(\neg x_4\).
The assignment \(x_1=1, x_2=1, x_3=1, x_4=0\) satisfies \(\varphi\). Picking vertices \(x_1 \in T_1\), \(x_2 \in T_2\), and \(\neg x_4 \in T_3\) gives an independent set of size \(3\).