- Describe how to build a binary adder that takes three numbers in at once in the form $(0 + 1)*$(0 + 1)*$(0 + 1)*and leaves their binary total on the TAPE.
- For consider the following grammar over the alphabet Σ = {a b c} :Derive the following words:(i) ababcc(ii) cbaabccba PROD 1 PROD 2 PROD 3 PROD 4 PROD 5 PROD 6 PROD 7 PROD 8 S → ABCS |
- Problem consider the following type 0 grammar over the alphabet Σ = {a b}:Derive the following words from this grammar:(i) Λ(ii) aa(iii) bb(iv) abab S →UVX UV-aUY UV-bUZ YX → VaX ZX →
- Problem consider the following type 0 grammar over the alphabet Σ = {a b}:Show that if w is any string of a's and b's, then the wordWWcan be generated by this grammar. S →UVX UV-aUY UV-bUZ YX →
- Consider the following type 0 grammar over the alphabet Σ = {a}.(i) Draw the total language tree of this language to find all words of five or fewer letters generated by this grammar.(ii) Generate
- Analyze the following type 0 grammar:(i) What are the four smallest words produced by this grammar?(ii) What is the language of this grammar? PROD 1 SA PROD 2 AaABC PROD 3 AabC PROD 4 CBBC PROD 5 bB
- A context-sensitive language is said to be in Kuroda normal form (after S . Y. Kuroda) if every production is of one of the following four forms:(i) Show that for every CSL there is a CSG in Kuroda
- In the proof that every type 1 grammar can be accepted by some TM, we simulated the productions of the grammar by a series of DELETEs followed by a series of INSERTs.(i) Show that if the grammar
- Trace these inputs on ADDER and explain what happens:(i) aaba(ii) aab(iii) baaa(iv) b
- (i) Build a TM that takes an input of three numbers in unary encoding separated by b's and leaves their sum on the TAPE.(ii) Build a TM that takes in any number of numbers in unary encoding separated
- Outline a TM that acts as a binary-to-unary converter, that is, it starts with a number in binary on the TAPE$(0 + 1)*$and leaves the equivalent number encoded in unary notation.
- Trace these inputs on MINUS and explain what happens:(i) aaabaa(ii) abaaa(iii) baa(iv) aaab
- Modify the TM MINUS so that it rejects all inputs not in the formba*ba*and convert banbam into ban-m.
- MINUS does proper subtraction on unary encoded numbers. Build a TM that does proper subtraction in binary encoded inputs.
- MAX is a unary machine; that is, it presumes its input numbers are fed into it in unary encoding. Build a machine (TM) that does the job of MAX on binary encoded input.
- Build a TM that takes in three n umbers in unary encoding and leaves only the largest of them on the TAPE.
- Trace the following strings on IDENTITY and SUCCESSOR:(i) aa(ii) aaaba
- Build machines that perform the same function as IDENTITY and SUCCESSOR but on binary encoded input.
- For consider the grammarDerive the following words from this grammar:(i) abba(ii) babaabbbaa PROD 1 PROD 2 ABBA PROD 3 BA AB S→ABS | A PROD 4 A-a PROD 5 B-b
- For the following CFGs, find regular expressions that define the same language and describe the language.(i)S → aX I bS I a I bX → aX I a(ii)S → bS I aX I bX → bX I aS I a
- For the following CFGs, find regular expressions that define the same language and describe the language.(i)S → aaS I abS I baS I bbS I Λ(ii)S → aB I bA I ΛA → aSB → bS
- For the following CFGs, find regular expressions that define the same language and describe the language.(i)S → aB I bAA → aB I aB → bA I b(ii)S → aS I bX I aX → aX I bY I aY → aY I a
- For the following CFGs, find regular expressions that define the same language and describe the language.(i)S → aS I bX I aX → aX I bY I bZ I aY → aY I aZ → aZ I bWW → aW I a(ii)S → bS I
- (i) Starting with the alphabetΣ = {a b ( ) + *}find a CFG that generates all regular expressions.(ii) Is this language regular?
- Each of the following CFGs has a production using the symbol Λ and yet Λ is not a word in its language. Using the algorithm in this chapter, show that there are other CFGs for these languages that
- Convert the following CFGs to CNF:(i)S → SS I a(ii)S → aSa I SSa I a(iii)S → aXXX → aS l bS l a(iv)E → E + EE → E*EE → (E)E → 7The terminals here are + * ( ) 7.(v)S→
- In convert the following FAs into equivalent PDAs. b b a a a b b
- Consider the following PDA:Trace the following words on this PDA:(i) aaabbb(ii) aaabab(iii) aaabaa(iv) aaaabb ACCEPT START READ, a PUSH a READ₂ a. b POP ACCEPT a READ3 POP
- In convert the following FAs into equivalent PDAs. a b h b b
- Convert the following CFGs with unit productions into CNF:(i)S → XX → YY → ZZ → aa(ii)S → SS I AA → SS I AS I a
- For consider the following nondeterministic PDA :In this machine, REJECT occurs when a string crashes. Notice here that the STACK alphabet is Γ = {x) .Show that this PDA accepts the language of all
- For consider the following nondeterministic PDA :In this machine, REJECT occurs when a string crashes. Notice here that the STACK alphabet is Γ = {x) .(i) Show that the string ab can be accepted by
- For consider the following nondeterministic PDA :In this machine, REJECT occurs when a string crashes. Notice here that the STACK alphabet is Γ = {x) .Here we have a nondeterministic PDA for a
- Build a deterministic PDA to accept the language {anbn+1}. (As always, when unspecified, the condition on n is assumed to be n = 1 , 2, 3 , . . . . )
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 is(i) S → aSbb I
- Let the input alphabet be Σ = { a b c } and L be the language of all words in which all the a's come before the b's and there are the same number of a's as b's and arbitrarily many c's that can be
- We have seen that an FA with N states can be converted into an equivalent PDA with N READ states (and no POP states). Show that for any FA with N states there is some PDA with only one READ state
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 isS → XaaXX → aX I
- Let L be some regular language in which all the words happen to have an even length. Let us de fine the new language Twist(L) to be the set of all the words of L twisted, where by twisted we mean the
- Given any language L that does not include Λ, let us define its cousin language I L I as follows: For any string of a's and b's, if the word formed by concatenating the second, fourth, sixth, . . .
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 isS → aS I aSbS I a
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 isS → Xa I Ybx →
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 isS → XYX → aX I
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 is(i) S → Saa I aSa
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 is(i) S → (S)(S) I
- For each of the CFGs below in construct a PDA that accepts the same language they generate, using the algorithm of Theorem 30).The PDA we produce by the algorithm of Theorem 30 is(i) S → XaY I
- Study this CFG for EVENPALINDROME:List all the derivation trees in this language that do not have two equal nonterminal on the same line of descent, that is, that do not have a self-embedded
- Show that if the algorithm of Theorem 31 produces a deterministic PDA, then the language has only one word in it.We shall now use the algorithm of Theorem 31 to tum this machine back into a CFG.
- (i) In a summary table for a PDA, can there be more rows with PUSH than rows with no PUSH?(ii) In a summary table for a PDA, can there be more rows that PUSH more than one letter than there are rows
- Find CFGs for these languages:(i) All words of the form(ii) All words of the form(iii) All words of the form(iv) All words of the form(v) What happens if we throw away the restrictions y > x and z
- Instead of the concept of live productions in CNF, let us define a live nonterminal to be one appearing at the left side of a live production. A dead nonterminal N is one with only productions of the
- Why does the pumping lemma argument not show that the language PALINDROME is not context-free? Show how v and y can be found such that uvn xyn z are all also in PALINDROME no matter what the word w
- Find CFGs for these languages:(i) All words that start with an a or are of the form anbn.(ii) All words that have an equal number of a's and b's or are of the form anbn.(iii) All words in
- (i) Take a PDA for PALINDROMEX and intersect it with an FA for a*Xa*. (This means actually build the intersection machine.)(ii) Analyze the resultant machine and show that the language it accepts is
- Prove that all CFGs with only the one nonterminal S and one or more live productions and one or more dead productions generate an infinite language.
- For the following grammars and target strings, decide whether or not the word is generated by the grammar using the CYK algorithm:S → SS x = abbaS → aS → bb
- For the following grammars and target strings, decide whether or not the word is generated by the grammar using the CYK algorithm:S → XS x = baabX → XXX → aS → b
- For the following grammars and target strings, decide whether or not the word is generated by the grammar using the CYK algorithm:S → XY x = abbaaX → SYY → SSX → a I bbY → aa
- The CYK algorithm can be described as bottom-up because it starts with the word and works up to the nonterminals. There is another method for deciding membership that is top-down in nature. Create a
- For the following grammars and target strings, decide whether or not the word is generated by the grammar using the CYK algorithm:S → AB x = bbaabA → BB I aB → AB I b
- For the following grammars and target strings, decide whether or not the word is generated by the grammar using the CYK algorithm:S → AB I CD I a I b x = babababA → aB → SAC
- Modify the CYK algorithm so that it applies to any CFG, not just those in CNF.
- The following is a version of an unambiguous grammar for arithmetic expressions employing - and / as well as + and *:Find a leftmost derivation in this grammar for the following expressions using the
- Using top-down parsing, find the leftmost derivation in the grammar PLUS-TIMES for the following expressions:(i) i + i + i(ii) i * i + i * i(iii) i * (i + i) * i(iv) ((i) * (i + i)) + i(v) (((i)) +
- For consider the following TM:Trace the execution chains of the following input strings on this machine:(i) aaa(ii) aba(iii) baaba(iv) ababb (a,a,L) (b,b,L) (#,#,R) 1
- For consider the following TM:The language accepted by this TM is all words with an odd number of letters that have a as the middle letter. Show that this is true by explaining the algorithm the
- Using bottom-up parsing, find any derivation in the grammar PLUS-TIMES for the following expressions:(i) i * (i)(ii) ((i) + ((i)))(iii) (i * i + i)(iv) i * (i + i)(v) (i * i) * i
- Refer to the following TM. We assume that the input string is put on the TAPE with the symbol # inserted in front of it in cell i. For example, the input ha will be run with the TAPE initially in the
- Using the second pushdown transducer, convert the following arithmetic expressions to postfix notation and then evaluate them on the first pushdown transducer:(i) 2 * (7 + 2)(ii) 3 * 4 + 7(iii) (3 +
- Refer to the following PM:(i) Show that if an input has exactly one more a than b, it will crash on this PM in state READ1.(ii) Show that if an input string has exactly one more b than a , it will
- Refer to the following PM:Trace the paths of the following input strings on this PM. At every step, name the current state and the contents of the STORE.(i) abab(ii) baabba(iii) aaabbb(iv) aabbbb(v)
- Refer to the following PM:Show that the language accepted by this PM is EQUAL, all words with the same number of a's and b's. READ₁ ADD a a START READ₂ b READ3 b ADD b ACCEPT a
- On the TM given in this chapter for the language {anbnan} , trace the following words:{i) aabbaa(ii) aabbaaa(iii) aabaa(iv) aabbaabb(v) Characterize the nature of the different input strings that
- Refer to the following PM:Draw a PM that accepts the language UNEQUAL, the complement of EQUAL. READ₁ ADD a a START READ₂ b READ3 b ADD b ACCEPT a
- Build a TM to accept the language {anbnan} based on the following algorithm :(i) Check that the input is in the form a*b*a* .(ii) Use DELETE in a n intelligent way.
- (i) Build a PM that takes in any string of a's and b's and leaves in its STORE the complement string that has the a's and b's switched.(ii) Build a PM that takes in any string of a's and b's and
- Build a PM that accepts the language MOREA (all words with more a's than b's) by using the following algorithm :Step 1 On one pass through the data, look for a pair of consecutive letters that are
- Consider the following 2PDA:Trace the execution of these input strings on this machine.(i) aabb(ii) babab ACCEPT PUSH₂ b POP₂ START READ POP₁ PUSH, a b POP₂
- In the description of the algorithm for the 3TM that does decimal addition "the way humans do," we skimmed too quickly over the conversion of data section. The input is presumed to be placed on track
- Build a PM that takes any input from the language defined by (a + b)* and deletes all substrings of the form aaa, leaving all else in the word intact.
- Build a PM that sorts the letters of a string. That is, if aba is fed in, the machine leaves aab in its STORE and accepts. Also, bbbaba becomes aabbbb.
- Convert these TMs to move-in-state machines:(i)(ii) START 1 7 (#.#.R) (b.#.R) (a.#.R) (a.b; =.L) (J,#;=,R) (a.b;=.l.) 2 3 HALT (a.b;=,R) (a.b;=,R) (a.b;=,R) (J.#: =.L.) (a.#.I.) (b.#.L) 5
- (i) Outline a TM that takes any input string of a's and b's and runs to HALT, leaving on its TAPE the same string reversed.(ii) Outline a PM that does the same thing.
- Let us use the alphabet Σ = {a b c d}. Build a 3PDA that accepts the language {anbncndn}.
- (i) Outline a 5TM that does decimal addition for three numbers simultaneously, the numbers being on tracks 2, 3, and 4. The sum should be left on track 5, and track 1 is reserved for carries.(ii)
- Outline a 5TM that multiplies two binary numbers initially on tracks 1 and 2. The product should be placed on track 3, using tracks 4 and 5 as a working area.
- Design a pattern that matches 2TM. The input is a long string on track 1 and a short string on track 2. The program halts only if the string on track 2 is a substring of the string on track 1.
- On a 2TM track 1 contains a string of the form (a + b)+ which is to be interpreted as a unary representation of numbers as strings of a's, separated by single b's.(i) Using a 2TM, find the largest of
- Outline a 2TM that takes as input on track 1 an and leaves on track 2 the binary representation of n.
- Outline an argument that shows how a two-way TM could b e simulated on a TM using the trick of interlacing cells on the TAPE. That is, the TAPE starts with a $ in cell i, and then cell ii represents
- Convert the following TMs first into summary tables and then into their code words in CWL. What are the six languages accepted by these TMs?(i)(ii)(iii)(iv)(v)(vi)Run each of the six encoded words on
- (i) Outline a proof that a nondeterministic PM has the same power as a regular PM.(ii) Outline a proof that a nondeterministic 2PDA has the same power as a regular 2PDA.
- (i) If we had introduced the proof that kTMs were the same as TMs earlier, would it have made the proof that PM = TM, or that 2PDA = TM, any easier?(ii) If we had introduced the proof that NTM = TM
- Given a TM, T1, and any string w, there is clearly a TM, T2, that first screens its input to see whether it is the particular string w; if it is not the input is accepted, if it is w, then T1 is run
- Decode the following words from CWL into their corresponding TMs and run them on their corresponding TMs to see which are in ALAN and which are in MATHISON:(i) abaabbbbab(ii) abaabaabba(iii)
- Which of the following FAs accepts a finite language and which an infinite one?(i)(ii)(iii)(iv) (1 b b (1 (1 a. b h b
- Describe the language generated by the following CFG : S→SS S→XXX XaX|Xa|b
- Let us, for the purposes of this problem only, allow a production of the formN1 → rN2where N1 and N2 are nonterminal and r is a regular expression. The meaning of this formula is that in any
- Consider the CFGWhat is the language this generates? Find a word in this language that can be generated in two substantially different ways. S→Xbaax ax X→Xa Xb|A
- Despite the fact that a CFG is not in regular form, it still might generate a regular language. If so, this means that there is another CFG that defines the same language and is in regular form. For