Lecture 8¶
Continue examples of Decidable Problems from the last lecture.
Example
C1 \(A_\text{CFG} = \{\langle G, w \rangle : G \text{ is a CFG that generates } w\}\).
\(M_{C1}\) = on input \(\langle G, w \rangle\)
- build an CFG \(G'\) in CNF equivalent to \(G\).
-
enumerate all the derivations of length \(2|w| - 1\).
Recap the property of CFG in CNF that if \(G\) generates a string of length \(n \ge 1\), then the length of derivation is exactly \(2n-1\).
-
if any of them generates \(w\),
- accept \(\langle G, w \rangle\),
- else,
- reject \(\langle G, w \rangle\).
C2 \(A_\text{PDA} = \{\langle P, w \rangle : P \text{ is a PDA that accepts } w\}\).
\(M_{C2}\) = on input \(\langle P, w \rangle\)
- build an CFG \(G\) equivalent to \(P\).
- run \(M_{C1}\) on \(\langle G, w \rangle\).
- output the result of \(M_{C1}\).
C3 \(E_\text{CFG} = \{\langle G \rangle : G \text{ is a CFG with } L(G) = \emptyset\}\).
\(M_{C3}\) = on input \(\langle G \rangle\)
- mark all terminals and \(e\).
- repeat the following until no new symbol is marked.
- for each rule that the right side is all marked symbols
- mark the left side symbols
- if start symbol is marked,
- reject,
- else,
- accept.
C4 \(E_\text{PDA} = \{\langle P \rangle : P \text{ is a PDA with } L(P) = \emptyset\}\).
Reduction¶
Now we give the formal definition of reduction.
Definition
Let \(A\) and \(B\) be two languages over \(\Sigma_A\) and \(\Sigma_B\) respectively. A reduction from \(A\) to \(B\) is a recursive / computable function \(f: \Sigma_A^* \rightarrow \Sigma_B^*\) such that for any \(x \in \Sigma_A^*\)
Theorem
Suppose that there exists a reduction \(f\) from \(A\) and \(B\). If \(B\) is recursive, A is recursive, denoted by \(A \le B\). (If A is not recursive, B is not recursive).
Proof
Since B is recursive, then there exists \(M_B\) decides \(B\).
\(M_A\) = on input \(x\),
- compute \(f(x)\).
- run \(M_B\) on \(f(x)\).
- output the result of \(M_B\).
Language Category¶
Now we know that enumerable recursive languages contain recusive languages. But we care about two questions:
- is there any language that is not enumerable?
- is there any language that is not recursive but enumerable recursive?
Before we dive in, let's recap something about equinumerosity.
Quote
Equinumerosity in DM.
Two sets have the same cardinality or say are equinumerous (等势的) iff there is a bijective from \(A\) to \(B\), i.e.\(|A| = |B|\).
A set is countable if it is equinumerous with \(\mathbb{N}\).
Lemma
\(A\) is countable iff there exists an injection \(f : A \rightarrow \mathbb{N}\).
Proof
\(\Rightarrow\) it's trivial.
\(\Leftarrow\) if A is finite, it's trivial. If not, sort \(A\) in increasing order of \(f(a)\) and let \(g(a)\) be the rank of \(a\).
Corollary
Any subset of a countable set is countable.
Theorem
Let \(\Sigma\) be an alphabet, then \(\Sigma^*\) is countable.
Since a Turing machine can be encoded in to a string, we have the following corollary
Corollary
\(\mathcal{M} = \{M : M \text{ is a TM}\}\) is countable.
Theorem
Let \(\Sigma\) be some non-empty alphabet, and \(\mathcal{L}\) be the set of all languages over \(\Sigma\). Then \(\mathcal{L}\) is uncountable.
Proof
Assume that \(\mathcal{L}\) is countable, then the langauges in \(\mathcal{L}\) can be labelled as
Since \(\Sigma^*\) is countable, then the string in \(\Sigma^*\) can be labelled as
We construct a set \(D = \{s_i | s_i \notin L_i\}\). Then for any \(i \in \mathbb{N}^*\), \(s_i \in D\) iff \(s_i \notin L_i\), and thus \(D \neq L_i\). Therefore \(D \notin \mathcal{L}\).
But \(D \in \Sigma^*\), and thus \(D\) is a language, which leads to a contradiction. So the assumption is false and \(\mathcal{L}\) is uncountable.
Since \(\mathcal{L}\) is uncountable while \(\mathcal{M}\) is countable, then we have the following fact.
Fact
There exists some language that is not recursively enumerable.
Now we define
Theorem
\(H\) is recursively enumerable.
Proof
\(U\) = on input \(\langle M, w \rangle\)
- run \(M\) on \(w\).
Then \(U\) halts on \(\langle M, w \rangle\) \(\Leftrightarrow\) \(M\) halts on \(w\) \(\Leftrightarrow\) \(\langle M, w \rangle \in H\).
We also call \(U\) universal TM. You can think \(U\) is a computer, since it run an algorithm \(M\) on some input \(w\). Both of the algorithm and input are programmable.
Theorem
\(H\) is not recursive.
Proof
Let \(H_d = \{\langle M \rangle : M \text{ is a TM that does NOT halt on } \langle M \rangle\}\)
Lemma 1
If \(H\) is recursive, then \(H_d\) is recursive.
Proof
Suppose \(H\) is recursive, then there exists a TM \(M_H\) that decides \(H\).
\(M_d\) = on input \(\langle M \rangle\)
- run \(M_H\) on \(\langle M, M \rangle\).
- if \(M_H\) accepts \(\langle M, M \rangle\),
- reject \(\langle M \rangle\),
- else,
- accept \(\langle M \rangle\).
Thus \(M_d\) decides \(H_d\) and \(H_d\) is recursive.
Lemma 2
\(H_d\) is NOT recursively enumerable.
Proof
Assume \(H_d\) is recursively enumerable, then there exists a TM \(D\) that semidecides \(H_d\).
Since \(D\) is a Turing machine, substitute \(M\) with \(D\), we have
It's a contradiction. So \(H_d\) is NOT recursively enumerable.
Combining Lemma 1 and Lemma 2, \(H\) is not recursive.
Now we get two key examples for the questions.
- \(H_d\) is not recursively enumerable.
- \(H\) is recursively enumerable but not recursive.
Examples of Reduction¶
Now that we have a powerful example \(H\), which is recursively enumerable but not recursive. So to prove some language that is also recursively enumerable but not recursive, we can use reduction: just reduct \(H\) to that langauge. Here we give some examples.
Example
Show that \(L_1 = \{\langle M \rangle : M \text{ is a TM that halts on } e\}\) is not recursive.
Proof
To use the reduction theorem, we need to construct some \(M'\), such that
\(M'\) = on input \(u\),
- run \(M\) on \(w\).
Well, that's all.
Example
Show that \(L_2 = \{\langle M \rangle : M \text{ is a TM that halts on some input} \}\) is not recursive.
Show that \(L_3 = \{\langle M \rangle : M \text{ is a TM that halts on every input} \}\) is not recursive.
Proof
Notice the proof in \(L_1\), we construct \(M'\). And actually we have
\(M'\) halts on \(e\) \(\Leftrightarrow\) \(M'\) halts on some input \(\Leftrightarrow\) \(M'\) halts on every input \(\Leftrightarrow\) \(M\) halts on \(w\).
So \(L_2\) and \(L_3\) is proved.
Example
Show that \(L_4 = \{\langle M_1, M_2 \rangle : M_1 \text{ and } M_2 \text{ are two TMs with } L(M_1) = L(M_2) \}\) is not recursive.
Proof
namely
\(M\) halts on every input, which means \(L(M) = \Sigma^*\). So we construct
\(M_1 = M\)
\(M_2\) = on input \(u\)
- halt.
创建日期: 2023.11.24 23:19:46 CST