# TDDC95 Introduction to the Theory of Computation 2013-08-31, kl. 14-18, Room TER1 ```TDDC95 Introduction to the Theory of
Computation
2013-08-31, kl. 14-18, Room TER1
Materials allowed: A dictionary from English to any other language is
allowed. No other books, notes etc. are allowed and no electronic
equipment (calculators, computer, mobile phones etc.) are allowed.
Questions: Christer Bäckström will show up after approx one hour and
is otherwise available on phone 0705-840889
Grading: The maximum number of points is 30 and 15 points are required
to pass the examination. At least 15 p is required for grade 3, at least
20 p is required for grade 4 and at least 25 p is required for grade 5.
Results: When the exams are graded there will be an opportunity to see
the exams and discuss the result with the examiner (this is called a
tentavisning in swedish). When and where this will happen will be
announced on the course homepage as soon as the grading is finished.
• Use only one side of each paper.
• Each problem must be solved on a separate paper (or several papers,
if necessary. Subproblems of a problem (a, b, c etc.) may be solved
on the same page.
justification, you may get zero points even if the answer is correct.
• Try to leave space for comments on every page.
Good luck!
Problems
1. Define the alphabet Σ = {0, 1, 2, 3} and the language L that consists (4 p)
of all strings over Σ such that the sum of the symbols in the string is
even. For example, the strings 022 and 12313 are both in L but 012
and 333 are not in L.
(a) Give a regular expression defining L.
(2)
(b) Draw the transition graph for a DFA that accepts L.
(2)
1
2. Consider the language L = {ak b∗ ck | k &gt; 0} over the alphabet Σ = (6 p)
{a, b, c}.
(a) Prove that L is not regular.
(4)
(b) Prove that L is a CFL by providing a CFG for L.
(2)
3. For any string s define the reverse string R(s) of s as the same string as (6 p)
s but with the symbols in opposite order. For example R(abab) = baba
and R(01231) = 13210. For any language L define the corresponding
reverse language R(L) as R(L) = {R(s) | s ∈ L}, i.e. R(L) consists of
the reverse strings for all strings in L.
(a) Prove that if L is a regular language, then also R(L) is a regular (3)
language, by explaining how to modify a regular grammar for L
to a regular grammar for R(L).
(b) Prove that if L is a CFL, then also R(L) is a CFL, by explaining (3)
how to modify a CFG for L to a CFG for R(L).
4.
(4 p)
(a) Is it meaningful to consider algorithms that run in polynomial (2)
time but exponential space?
(b) NP-complete is an important and useful concept. Is it meaningful (2)
to consider a corresponding concept P-complete for the class P?
5. Adding a stack to a DFA gives a pushdown automaton, which is a (4 p)
strictly more powerful concept. What if we add a stack to a deterministic Turing machine, would that give a more powerful concept?
6. For each of the following 3 problems, prove that the problem is in NP (6 p)
or explain why this cannot be proven (with our current knowledge).
(a) AndSat
Input: Two 3CNF formulae ϕ and ψ.
Question: Are both ϕ and ψ satisfiable?
(2)
(b) OrSat
Input: Two 3CNF formulae ϕ and ψ.
Question: Is at least one of ϕ and ψ satisfiable?
(2)
(c) XorSat
Input: Two 3CNF formulae ϕ and ψ.
Question: Is exactly one of ϕ and ψ satisfiable?
(2)
2
```