105 Practice Final Solution Outline

The following is a solution outline for the practice final. I did this quickly by your request so let me know before the weekend if there are any major gaffs! Please generate your own solutions before you look at these!

1. Consider the context-free grammar G=(V,T,P,S) where P is the set of productions:
S-->aB
B-->Sbb
S--> epsilon

2. Consider the PDA M=({q0,q1,q2},{a},{A,B},delta,q0,A,{q0}) with instructions delta(q0,a,A)={(q1,BA)}, delta(q1,a,B)={(q0,epsilon)} and delta({q1,epsilon,B)={(q2,B)}.

3. Fill in the following chart with Y if the set of languages in the row is closed under the property in the column and N if it is not.
Give a brief justification for 2 of your answers in each row.

unionintersectionconcatenationcomplement
regular languagesYYYY
context-free languagesYNYN
recursive languagesYYYY
r.e. languagesYYYN

The proofs for regular languages are shown in the book in section 3.2.

The Y proofs for for context-free languages are shown in section 6.2.

The N proof for the intersection of context-free languages is based on the following: L1 = {aibicj} and L2 = {aibjcj} are both CFLs but their intersection L3 = {aibici} is not a CFL by the pumping lemma for CFLs.

The N proof for the complement of a context-free language is based on the following: If context-free languages were closed under both union and complement then they would be closed under intersection. They are not closed under intersection and they are closed under union, so they must not be closed under complement.

The proofs for recursive languages are shown in the book in section 8.2. Intersection can be shown by constructing a machine which interleaves the computations of two machines. Concatenation can be shown by nondeterministically guessing the boundary between the end of the first substring of the concatenated string and the beginning of the second substring of the concatenated string. The "concatenation machine" executes the first machine on the first part and and the second machine on the second part. To be a concatenated string, both substring executions must terminate with a Y. Note that if an input string is a concatenation, some nondeterministic guess at the boundary will provide an accepting computation.

For r.e. languages, U and complement are covered in section 8.2. For concatenation, construct a 2 tape TM which nondeterministically guesses the boundary between the first and second substrings. Put the first string on the first tape and the second string on the second tape and interleave the execution of both machines. For intersection, you can also use a 2 tape turing machine. Copy the string on the second tape and interleave computations on the first and second tape. If the machine simulated by the first tape and the machine simulated by the second tape both accept, then make your constructed "intersection TM" accept the string.

4. Consider the language L={0n1n2n| n > 0}.

5. Let M=({q0},{1},{1,B},delta,q0,B,F) be a Turing machine with instructions delta(q0,1)=(q0,1,R) and delta(q0,B)=(q0,B,R).

6. What kind of machines accept r.e. languages?

What kind of machines accept recursive languages? Which one of these classes is a subset of the other? Is this a proper subset (i.e. the two classes are not equal)? Why or why not?

7. Consider the following classes: recursively enumerable (r.e.) languages, languages accepted by deterministic FSAs, context-free languages (CFLs), recursive languages, all languages, regular langugages, deterministic context-free languages (DCFLs), languages accepted by DTMs.

Draw a diagram which shows the subset relationships between these languages.

For the given language classes, show by exhibiting particular languages, which subset relationships in the diagram are proper. For example, if you have claimed that language class A is a proper subset of language class B, then give an example of a language that is in class B but not in class A.

8. Show that it is undecidable to determine the following question: "Given TMs M1 and M2, is L(M1)=L(M2)?".