Theory of Computation 8 Deterministic Membership Testing

Similar documents
Theory of Computation 7 Normalforms and Algorithms

Ogden s Lemma for CFLs

NPDA, CFG equivalence

Theory of Computation 1 Sets and Regular Expressions

CS4232 Theory of Computation

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Advanced Automata Theory 2 Finite Automata

Theory of Computation 3 Deterministic Finite Automata

Theory of Computation 4 Non-Deterministic Finite Automata

Properties of Context-Free Languages

Foundations of Informatics: a Bridging Course

Advanced Automata Theory 7 Automatic Functions

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Properties of Context-Free Languages. Closure Properties Decision Properties

MA/CSSE 474 Theory of Computation

Theory Bridge Exam Example Questions

Final exam study sheet for CS3719 Turing machines and decidability.

Non-context-Free Languages. CS215, Lecture 5 c

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

Properties of context-free Languages

Functions on languages:

Chap. 7 Properties of Context-free Languages

DM17. Beregnelighed. Jacob Aae Mikkelsen

CS5236 Advanced Automata Theory

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CPSC 421: Tutorial #1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS481F01 Prelim 2 Solutions

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

CSE 468, Fall 2006 Homework solutions 1

This lecture covers Chapter 7 of HMU: Properties of CFLs

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

V Honors Theory of Computation

Properties of Context-free Languages. Reading: Chapter 7

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Context-Free Languages (Pre Lecture)

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Context Free Language Properties

The Pumping Lemma and Closure Properties

Deterministic Finite Automaton (DFA)

CS500 Homework #2 Solutions

ACS2: Decidability Decidability

Theory of Computation (Classroom Practice Booklet Solutions)

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

3515ICT: Theory of Computation. Regular languages

THEORY OF COMPUTATION

Lecture 17: Language Recognition

Sri vidya college of engineering and technology

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

Advanced Automata Theory 11 Regular Languages and Learning Theory

CSE 105 THEORY OF COMPUTATION

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

CS20a: summary (Oct 24, 2002)

CS 455/555: Finite automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Automata and Computability. Solutions to Exercises

Introduction to Turing Machines. Reading: Chapters 8 & 9

Decidability (What, stuff is unsolvable?)

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Languages, regular languages, finite automata

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Context-Free and Noncontext-Free Languages

Theory of Computation Turing Machine and Pushdown Automata

Advanced topic: Space complexity

Theory of computation: initial remarks (Chapter 11)

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

TAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar

UNIT-VIII COMPUTABILITY THEORY

Chapter 2: Finite Automata

Notes for Comp 497 (Comp 454) Week 10 4/5/05

CS375: Logic and Theory of Computing

Space Complexity. The space complexity of a program is how much memory it uses.

CISC4090: Theory of Computation

Automata and Computability. Solutions to Exercises

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars

Even More on Dynamic Programming

CSE 105 THEORY OF COMPUTATION

Section 1 (closed-book) Total points 30

Formal Languages and Automata

Context-Free Grammars (and Languages) Lecture 7

Notes for Comp 497 (454) Week 10

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CSC173 Workshop: 13 Sept. Notes

Computational Models - Lecture 5 1

Computational Models - Lecture 4

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Regular Expressions and Language Properties

Probabilistic Aspects of Computer Science: Probabilistic Automata

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

The View Over The Horizon

Section 14.1 Computability then else

Chapter 6. Properties of Regular Languages

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Equivalence of Regular Expressions and FSMs

Grammars and Context Free Languages

Transcription:

Theory of Computation 8 Deterministic Membership Testing Frank Stephan Department of Computer Science Department of Mathematics National University of Singapore fstephan@comp.nus.edu.sg Theory of Computation 8 Deterministic Membership Testing p. 1

Repetition 1: Normal Forms The normal forms are named after Noam Chomsky (born 1928) and Sheila Greibach (born 1939). Assume that the language does not contain ε. Chomsky Normal Form All rules are of the form A BC or A d where A,B,C are non-terminals and d is a terminal. Greibach Normal Form All rules are of the form A bw where b is a terminal and A a non-terminal and w a (possibly empty) word of non-terminals. If the language contains ε, one permits in both normal forms S ε for the start symbol S which then is not permitted to appear on the right side of a rule. Theory of Computation 8 Deterministic Membership Testing p. 2

Repetition 2: Algorithms Given a context-free grammar as input, algorithms for the following tasks where presented: Converting the grammar into Chomsky Normal Form; Testing whether the grammar generates a word; Testing whether the grammar generates infinitely many words. All these algorithms run in time polynomial in the size of the grammar; for grammars in Chomsky Normal Form, the number of non-terminals can serve as the size. Theory of Computation 8 Deterministic Membership Testing p. 3

Repetition 3: Derivation Tree For grammar ({S, T, U},{0, 1},{S SS TU UT, U 0 US SU, T 1 TS ST},S), a derivation S TU TSU TUTU 1UTU 10TU 101U 1010 can be represented by a tree: S T U T S 0 1 U T 0 1 Theory of Computation 8 Deterministic Membership Testing p. 4

Repetition 4 Marked Symbols Mark the first four 1 in word 0000011111 as 0000011111. The word can be pumped such that at least one but at most four marked symbols are pumped or between the pumped parts: 0000 l 011 l 111. Ogden s Lemma Let L Σ be an infinite context-free language generated by a grammar (N,Σ,P,S) in Chomsky Normal Form with h non-terminals. Then the constant k = 2 h+1 satisfies that for every u L with at least k marked symbols, there is a representation vwxyz = u such that wxy contains at most k marked symbols, wy contains at least 1 marked symbol and vw l xy l z L for all l N. Theory of Computation 8 Deterministic Membership Testing p. 5

Membership Testing For a language L and a word w of length n, one wants to decide whether w L. The following will be shown: Regular language: Done by a finite automaton, time O(n). Linear language: Special case of Cocke, Kasami and Younger s algorithm, time O(n 2 ). Context-free language: Cocke, Kasami and Younger s algorithm, time O(n 3 ). Context-sensitive language: Savitch s algorithm, space O(n 2 ), time O(c n2 ) for some c. Recursively enumerable language: No algorithm (undecidable). Theory of Computation 8 Deterministic Membership Testing p. 6

Cocke, Kasami and Younger Let (N,Σ,P,S) be in Chomsky Normal Form and a 1 a 2...a n be the input word. 1. Initialisation: For all k, E k,k = {A N : A a k is a rule}. 2. Loop: Go through all pairs (i,j) such that they are processed in increasing order of j i and let E i,j = {A : rule A BC k [i k < j and B E i,k and C E k+1,j ]}. 3. Decision: Word is generated by the grammar iff S E 1,n. Set E i,j contains all non-terminals generating a i...a j. Time O(n 3 ): O(n 2 ) values E i,j with O(n) choices of k. Theory of Computation 8 Deterministic Membership Testing p. 7

Example 8.2, Word 0011 Grammar ({S,T,U},{0,1},{S SS TU UT, U 0 US SU,T 1 TS ST},S). Entries E i,j : E 1,4 = {S} E 1,3 = {U} E 2,4 = {T} E 1,2 = E 2,3 = {S} E 3,4 = E 1,1 = {U} E 2,2 = {U} E 3,3 = {T} E 4,4 = {T} 0 0 1 1 As S E 1,4, the word 0011 is in the language. Theory of Computation 8 Deterministic Membership Testing p. 8

Example 8.2, Word 0111 Grammar ({S,T,U},{0,1},{S SS TU UT, U 0 US SU,T 1 TS ST},S). Entries E i,j : E 1,4 = E 1,3 = {T} E 2,4 = E 1,2 = {S} E 2,3 = E 3,4 = E 1,1 = {U} E 2,2 = {T} E 3,3 = {T} E 4,4 = {T} 0 1 1 1 As S / E 1,4, the word 0111 is not in the language. Quiz 8.3 Make the table for word 1001. Theory of Computation 8 Deterministic Membership Testing p. 9

Cocke, Kasami and Younger Exercise 8.4 Consider the grammar ({S,T,U,V,W},{0,1,2},P,S) with P consisting of the rules S TT, T UU VV WW, U VW WV VV WW, V 0, W 1. Make the entries of the Algorithm of Cocke, Kasami and Younger for the words 0011, 1100 and 0101. Exercise 8.5 Consider the grammar ({S,T,U,V,W},{0,1,2},P,S) with P consisting of the rules S ST 0 1, T TU 1, U UV 0, V VW 1, W 0. Make the entries of the Algorithm of Cocke, Kasami and Younger for the word 001101. Theory of Computation 8 Deterministic Membership Testing p. 10

Linear Grammars Linear languages sit between regular and context-free languages. Definition A grammar is linear iff on every left side of a rule exactly one non-terminal and on every right side of a rule at most one non-terminal and arbitrary many terminals. Normal Form A linear grammar for a language not containing ε is in normal form iff all rules are of one of the following forms: A Bc, A cb, A c where A,B are non-terminals and c is a terminal. Theory of Computation 8 Deterministic Membership Testing p. 11

Parsing Linear Grammars Let (N,Σ,P,S) be a linear grammar in normal form and a 1 a 2...a n be an input word. 1. Initialisation: For all k, E k,k = {A N : A a k is in P}. 2. Loop: Process all pairs (i,j) with i < j in increasing order of j i and let E i,j = {A : rule A Bc [B E i,j 1 and c = a j ] or rule A cb [c = a i and B E i+1,j ]}. 3. Decision: The word is generated by the grammar iff S E 1,n. Theory of Computation 8 Deterministic Membership Testing p. 12

Example 8.8, Word 0110 The grammar ({S,T,U},{0,1},{S 0 1 0T 1U,T S0 0,U S1 1},S) is a linear grammar for palindromes. For the word 0110, the entries are E 1,4 = {S} E 1,3 = E 2,4 = {T} E 1,2 = {U} E 2,3 = {S,U} E 3,4 = {T} E 1,1 = {S,T} E 2,2 = {S,U} E 3,3 = {S,U} E 4,4 = {S,T 0 1 1 0 and as S E 1,4, the word is accepted. Theory of Computation 8 Deterministic Membership Testing p. 13

Example 8.8, Word 1110 For processing the word 1110, one gets the following table: E 1,4 = {T} E 1,3 = {S,U} E 2,4 = {T} E 1,2 = {S,U} E 2,3 = {S,U} E 3,4 = {T} E 1,1 = {S,U} E 2,2 = {S,U} E 3,3 = {S,U} E 4,4 = {S,T} 1 1 1 0 Exercise 8.9 Make the entries for the word 0110110 for above grammar. Theory of Computation 8 Deterministic Membership Testing p. 14

Exercises 8.10 and 8.11 Exercise 8.10 Consider the following linear grammar: ({S,T,U},{0,1},{S 0T T0 0U U0, T 0T00 1, U 00U0 1},S). Convert the grammar into the normal form and determine the E i,j for input 00100. Exercise 8.11 Which two of the following languages are linear? Provide linear grammars for these two languages: L = {0 n 1 m 2 k : n+k = m}; H = {0 n 1 m 2 k : n+m = k}; K = {0 n 1 m 2 k : n m or m k}. Theory of Computation 8 Deterministic Membership Testing p. 15

Kleene Star Algorithm 8.12 Let L be generated by a linear grammar and a 1 a 2...a n be a word. To check whether a 1 a 2...a n L, do the following: First Part: Compute for each i,j with 1 i j n the set E i,j of all non-terminals which generate a i a i+1...a j. Initialise Loop for Kleene Star: Let F 0 = 1. Loop for Kleene Star: For m = 1,2,...,n Do Begin If there is a k < m with S E k+1,m and F k = 1 Then let F m = 1 Else let F m = 0 End. Decision: w L iff F n = 1. First Part is O(n 2 ), Loop for Kleene Star is O(n 2 ). Theory of Computation 8 Deterministic Membership Testing p. 16

Other Combinations Assume that H,K,L are linear languages and that one has computed for a 1...a n the entries E L i,j,eh i,j,ek i,j say whether the word a i...a j is in L,H,K, respectively. This information can be computed in O(n 2 ). Complete the algorithm to do the following check in O(n 2 ) time: Exercise 8.13 Is a 1 a 2...a n L H K? Exercise 8.14 Is a 1 a 2...a n (L H) K? Theory of Computation 8 Deterministic Membership Testing p. 17

Regular Closure of CTF A language H is said to be in the regular closure of the context-free languages iff it is obtained by combining finitely many context-free languages with intersection, union, concatenation, set-difference, Kleene Star and Kleene Plus. An example is H = (L 1 L 2 ) L 3 (L 1 L 2 ) L 4 and here L 1,L 2,L 3,L 4 are context-free. Exercise 8.15 Prove by structural induction that every language H which is in the regular closure of the context-free languages has an O(n 3 ) decision algorithm. Theory of Computation 8 Deterministic Membership Testing p. 18

Counting Derivation Trees One can modify the algorithm of Cocke, Kasami and Younger to count derivation trees. Given grammar in CNF (N,Σ,P,S), a word w = a 1 a 2...a n and all A N, let E i,j denote the set of all nonterminals which generate the characters a i...a j and D i,j,a denote the number of derivation trees which can, with root A, derive a word a i...a j. Let P be the set of rules. For each A N, if A E i,i, there is exactly one tree with A a i and so D i,i,a = 1 else D i,i,a = 0. If i < j then D i,j,a = (B,C): A BC P k: i k<j D i,k,b D k+1,j,c and the overall number of derivation trees is D 1,n,S. Theory of Computation 8 Deterministic Membership Testing p. 19

Exercises 8.17-8.20 Let P contain the rules V VV WW 0 and W VW WV 1. Consider the grammars G = ({V,W},{0,1},P,W) and H = ({U,V,W},{0,1,2},P {U VU UV 2},U). Exercise 8.17 How many derivation trees has 0011100 in G? Exercise 8.18 How many derivation trees has 0000111 in G? Exercise 8.19 How many derivation trees has 021111 in H? Exercise 8.20 How many derivation trees has 010012 in H? Theory of Computation 8 Deterministic Membership Testing p. 20

Polynomial Space An algorithm can be measured by The time needed to do the computation; The space (size of variables and arrays and...) needed to do the computation. Let n be a parameter to measure the size of the input. If one can be computed in time F(n) then, under certain assumptions to the machine model, it can also be done in space F(n). However, for the converse, only a rough estimate is known: If something can be computed in space F(n) then one can compute it in time 2 F(n). Theory of Computation 8 Deterministic Membership Testing p. 21

Theorem of Savitch Algorithm 8.21 Context-senstive grammar (N,Σ,P,S), input word w. Recursive Call: Function Check(u,v,t) Begin If u = v or u v Then Return(1); If t 1 and u v and u v Then Return(0); Let t = t/2; Let r = 0; For all u (N Σ) with u u v Do Begin If Check(u,u,t ) = 1 and Check(u,v,t ) = 1 Then r = 1 End; Return(r ) End. Decision: If Check(S,w,k n ) = 1 Then w L Else w / L. Space Complexity, per call O(n), in total O(n 2 ); Value of t: k n /2 h in depth h of recursion (k = Σ + N +1); Number of nested calls: O(log(k n )) = O(log(k) n). Runtime: O(c n2 ) for any c > (2k) log(k). Theory of Computation 8 Deterministic Membership Testing p. 22

Example Check whether S w within 8 steps. One call Check(S, w, 8). Is there a word v such that S v and v w both within 4 steps? For each v, two calls Check(α,β,4) one after each other with (α,β) = (S,v),(v,w). Is there a word v such that α v and v β both within 2 steps? For each word v, two calls Check(α,β,2) one after each other with (α,β ) = (α,v ),(v,β ). Is there a word v such that α v and v β both within 1 steps? For each word v, two calls Check(α,β,1) one after each other with (α,β ) = (α,v ),(v,β ). Is α = β or α β true? No further call needed, bottom of recursion reached. Theory of Computation 8 Deterministic Membership Testing p. 23

Example 8.22 Consider grammar ({S, T, U, V, W},{0, 1}, P, S) with rules P being the following: S 0S U, U V 0, 0V 1U, V 1, 1V WU, 1W W0, 0W 10. This gives a binary counter with S 0S generating enough digits before doing S U. U stands for last digit 0, V stands for last digit 1, W stands for a digit 0 still having a carry bit to pass on. Deriving a binary number k needs at least k steps; as the length n of k is logarithmic in k, the derivation length can be exponential in n. In particular deriving 1 n needs more than 2 n steps. Theory of Computation 8 Deterministic Membership Testing p. 24

Exercises 8.23 and 8.24 Exercise 8.23 Give a proof that there are k n or less words of length up to n over the alphabet Σ N with k 1 symbols. Exercise 8.24 Modify Savitch s Algorithm such that it computes the length of the shortest derivation of a word w in the context-sensitive grammar, provided that such derivation exists. If it does not exist, the algorithm should return the special value. Theory of Computation 8 Deterministic Membership Testing p. 25

Naive Algorithm Exercise 8.25 What is the time and space complexity of this naive algorithm? Recursive Call: Function Check(u,w,t) Begin If u = w or u w Then Return(1); If t 1 and u v and u w Then Return(0); Let r = 0; For all v (N Σ) with u v and v w Do Begin If Check(v,w,t 1) = 1 Then r = 1 End; Return(r ) End; Decision: If Check(S,w,k n ) = 1 Then w L Else w / L. Theory of Computation 8 Deterministic Membership Testing p. 26

Growing Grammars Definition [Dahlhaus and Warmuth 1986] A grammar (N,Σ,P,S) is growing context-sensitive iff l < r for all rules l r in the grammar. Theorem [Dahlhaus and Warmuth 1986] Given a growing context-senstive grammar there is a polynomial time algorithm which decides membership of the language generated by this growing grammar. In this result, polynomial time means here only with respect to the words in the language, the dependence on the size of the grammar is not polynomial time. So if one asks the uniform decision problem for an input consisting of a pair of a grammar and a word, no polynomial time algorithm is known for this problem. As the problem is NP-complete, the algorithm is unlikely to exist. Theory of Computation 8 Deterministic Membership Testing p. 27

Example 8.28 Consider the grammar ({S,T,U},{0,1},{S 011 T11,T T0U 00U,U0 0UU,U1 111},S) which is growing. This grammar has derivations like S T11 00U11 001111 and S 0T11 T0U11 0U0U11 00U01111 000UU1111 000U111111 00011111111. The language of the grammar is {0 n 1 2n : n > 0} = {011,001111,0 3 1 8,0 4 1 16,0 5 1 32,...} and not context-free, as infinite languages satisfying the context-free pumping lemma can only have constant gaps (sequence of lengths without a word). This grammar has growing gaps. Theory of Computation 8 Deterministic Membership Testing p. 28

Exercises 8.29-8.31 Exercise 8.29 Show that every context-free language is the union of a language generated by a growing grammar and a language containing only words up to length 1. Exercise 8.30 Modify the proof of Theorem 6.11 to prove that every recursively enumerable language, that is, every language generated by some grammar is the homomorphic image of a language generated by a growing context-sensitive grammar. Exercise 8.31 Construct a growing grammar for the language {1 2n 0 2n 1 2n : n > 0} which is the palindromisation of the language from Example 8.28. Theory of Computation 8 Deterministic Membership Testing p. 29

Repetition for 16.10.2017, A B David Belanger (belanger@math.nus.edu.sg) will conduct the tutorials on 16.10.2017 and go through the following exercises (which do not carry marks). Exercise A. Provide a regular expression for all words which have either the subword 110 or the subword 120 over the ternary alphabet {0, 1, 2}. Exercise B. Use structural induction to define L mi = {w mi : w L} for all regular sets L. So first define this for all sets containing words up to length 1 and then explain, how one goes on with concatenation, union, Kleene star and Kleene plus. Sets consisting of words of length at least 2 can be obtained from the base cases this way. Theory of Computation 8 Deterministic Membership Testing p. 30

Repetition for 16.10.2017, C E Exercise C. Provide a DFA accepting those binary numbers which are multiples of 3: 11, 110, 1001, 1100, 1111, 10010, 10101, 11000,11011 and so on. Exercise D. Construct over the ternary alphabet {0,1,2} a DFA which accepts all words which contain each of the digits an odd number of times. Exercise E. Provide a non-deterministic finite automaton of thirteen states which accepts all decimal numbers which are not a multiple of 210; for this note that 0 is also a multiple of 210 and should be rejected. The numbers accepted should not having leading zeroes. Theory of Computation 8 Deterministic Membership Testing p. 31

Repetition for 16.10.2017, F H Exercise F. Construct a context-free grammar in Chomsky Normal Form for the language {0 n 1 m 2 n : n,m N}. Exercise G. Construct a context-free grammar in Greibach Normal Form for the language {0 n 1 m 2 n : n,m N}. Exercise H. Use the grammar from F and the Cocke Kasami Younger algorithm to check whether F generates the following words: 00122 and 00112. Theory of Computation 8 Deterministic Membership Testing p. 32

Repetition for 16.10.2017, I K Exercise I. Recall that a language L satisfies the weakest form of the Pumping Lemma iff there is a constant k such that all words of length at least k in L can be split into parts xyz with y ε and {x} {y} {z} L. Which of the following choices for L satisfy this pumping lemma: 1. L = {0 n 1 m 2 n : n,m N}; 2. L = {0 n 1 m 0 n : n,m N}; 3. L = {0 n 1 m 2 k : n+k m}? Exercise J. Which of the languages in Exercise I have a linear grammar? Exercise K. Use Ogden s Lemma to prove that the language {0 n 1 m 2 k : n m n k m k} is not context-free. Theory of Computation 8 Deterministic Membership Testing p. 33

Additional Exercises L O Let h, k be homomorphisms with h(a) = a, h(b) = ε, k(a) = ε and k(b) = b for a {0,1,2,3,4} and b {5, 6, 7, 8, 9}. Prove the following statements for L {0,1,2,3,4,5,6,7,8,9}. Exercise L. If k(l),h(l) are both regular then L is regular. Exercise M. If k(l) is deterministic context-free and h(l) regular then L is deterministic context-free. Exercise N. There is an L for which h(l),k(l) are both context-free but L is not. Exercise O. If k(l),h(l) are context-sensitive languages not containing ε, so is L. Theory of Computation 8 Deterministic Membership Testing p. 34

Additional Exercises P S Do for L = {w {000,111,222} + : w is a palindrome} the following exercises. Exercise P. Which is the least constant k such that every word w L can be split into three parts x,y,z with w = xyz and 1 y k and xy z L. Give the answer if there is no such constant k. Exercise Q. Provide a context-free grammar in Chomsky Normal Form for L. Exercise R. Provide a context-free grammar in Greibach Normal Form for L. Exercise S. Provide a PDA accepting by state for L. Can this PDA be made deterministic? Give a short reason for the answer. Theory of Computation 8 Deterministic Membership Testing p. 35

Additional Exercises T W Prove that the following functions are primitive recursive. Exercise T. Function f(n) = n 2. Exercise U. Function g(n) = n n. Exercise V. Function h(m,n) = ( m+n m Exercise W. Function k(m, n) = m! + n!. ). Theory of Computation 8 Deterministic Membership Testing p. 36

Additional Exercises X-Z Exercise X. Is it decidable to check whether a polynomial with integer coefficients and one input variable x takes on some input the value 1024? For example, for input function f(x) = x 2 +1, one wants to check whether there is an integer x with f(x) = 1024. Prove the answer. Exercise Y. Let ϕ 0,ϕ 1,... be an acceptable numbering of all partial-recursive functions. Is L = {e : ϕ e (x) is undefined for some x} recursively enumerable? Prove the answer using Rice s Theorem. Exercise Z. Let ϕ 0,ϕ 1,... be an acceptable numbering of all partial-recursive functions. Is H = {e : the domain of ϕ e is the range of a primitive recursive function} (a) decidable, (b) recursively enumerable and undecidable, (c) not recursively enumerable? Prove the answer using Rice s Theorem. Theory of Computation 8 Deterministic Membership Testing p. 37