TDDD65 Introduction to the Theory of Computation Example Examination 2

advertisement
2012-09-28
Linköpings Tekniska Högskola
Institutionen för Datavetenskap
Gustav Nordh
TDDD65 Introduction to the Theory of Computation
Example Examination 2
Material allowed:
Questions:
Grading
Results
An English dictionary (to any language) is allowed. Other material (like books,
lecture notes, own notes etc. ) and electronic equipment (computers, calculators,
mobile phones etc.) is not allowed.
Gustav Nordh, 0739 871855, will appear in the examination room around
XX.XX
There are 8 problems giving max 24 points. To pass you need 12 points. The
lower bounds of points for the grades 3,4,5 are as follows: 3:12, 4:17, 5:21.
An announcement will be posted at the course homepage approx. one week
after the exam with information on where you can look at your graded exam
and discuss the result with the examiner.
Please observe the following:
• Solutions to different problems should be placed one-sided on separate page(s).
• Justify your answers properly: missing or insufficient explanations will result in reduction of
points.
• Be sure that your answers are readable.
• Leave space for comments.
Good luck!
1
1. Recall that kSAT is the problem of checking the satisfiability of kCNF-formulas, i.e., checking
the satisfiability of conjunctions of clauses with k literals. For example,
(4 p)
(x1 ∨ x1 ∨ x2 ) ∧ (x1 ∨ x2 ∨ x2 ) ∧ (x1 ∨ x2 ∨ x2 )
is a satisfiable 3CNF-formula, and
(x1 ∨ x2 ) ∧ (x1 ∨ x2 ) ∧ (x1 ∨ x2 ) ∧ (x1 ∨ x2 )
is an unsatisfiable 2CNF-formula.
Consider the following (claimed) polynomial-time mapping reduction from 3SAT to 2SAT.
Input: A 3CNF formula ϕ
Output: A 2CNF formula γ
Find a satisfying assignment to ϕ (if none exists, output γ = 0). For every clause Ci of ϕ
that has 3 literals, there are two cases. If all the literals are set to 1, then we simply drop one
literal arbitrarily. If some literal is set to 0, we drop that literal, resolving choices arbitrarily.
After processing all such 3-literal clauses, the resulting formula is the desired 2CNF formula.
The reduction runs in polynomial time because we make a single pass over the formula.
The reduction is correct because if ϕ is satisfiable, then by construction, the same satisfying
assignment satisfies γ. If ϕ is unsatisfiable, then γ = 0 is not satisfiable. Thus, 3SAT is
polynomial-time mapping reducible to 2SAT.
(a) This reduction (if correct) would have one major and surprising consequence, which
one?
(1)
(b) The reduction is indeed wrong. There is one big error. Explain what is the error.
(3)
2. In certain programming languages, comments appear between delimiters such as // and \\.
Let L be the language of all valid comment strings. A member of L1 must begin with // and
end with \\. For simplicity we assume that the only other symbols allowed in a comment
string is a and b. Hence, the alphabet of L is Σ = {a, b, /, \}.
(2 p)
For example, //ab/\\ba\a\\ is in L.
Give a regular expression generating L.
3. The language L over the alphabet Σ = {a, b, c} consists of all strings over Σ in which at least
one a is followed by a b, or at least one c is followed by an a. So for example, abbcc ∈ L and
bbacca ∈ L but bbaaac ∈
/ L. Draw the transition graph of a 4-state NFA N that recognize L.
(2 p)
4. Convert the following NFA to an equivalent DFA using the subset construction.
(2 p)
a
p
a
ε
q
r
b
5. The P vs. N P problem is currently one of the most important open problems in all of
mathematics.
2
(3 p)
(a) Write down one argument for why it might be the case that P = N P .
(1)
(b) Write down one argument for why it might be the case that P 6= N P .
(1)
(c) Write down one reason why the P vs. N P problem has not been resolved yet.
(1)
6. Consider the following CFG G1 , where a, b are terminals, S, A, B are variables, and S is
the start variable:
S → ASA | BSB | AA | BB
A→a | ε
B→b | ε
(a) Prove that G1 is ambiguous.
(4 p)
(2)
(b) Construct a new unambiguous CFG G2 such that L(G2 ) = L(G1 ).
(You neither need to
(2)
prove that G2 is unambiguous nor that L(G2 ) = L(G1 ).)
7. Consider the language L (over the alphabet Σ = {a, b, c}) defined as {ai bj ck | i > j > k > 0}.
(4 p)
Use the pumping lemma to prove that L is nonregular.
8. Consider the languages A, B, and C, where A is a regular language, B is not Turing
recognizable, and C is recognized by a Turing machine that loops on some inputs. Given the
following mapping reductions:
• C ≤m A,
• F ≤m B,
• B ≤m D,
• C ≤m B,
• E ≤m C, and
• C ≤m F ,
what can you conclude about the decidability of the languages D, E, and F ? More specifically for each of D, E, and F answer whether it is decidable, undecidable, or whether the
information given is not enough to draw a conclusion.
3
(3 p)
Download