Regular Languages
[73/75%]ᴬ The following are the state diagrams of two DFAs, and . Answer the following questions about each of these machines.
What is the start state?
What is the set of accept states?
What sequence of states does the machine go through on input aabb?
Does the machine accept the string aabb?
Does the machine accept the string ?
ᴬ Give the formal description of the machines and pictured in Exercise 1.1.
The formal description of a DFA is , where is given by the following table. Give the state diagram of this machine.
| u | d | |
|---|---|---|
Each of the following languages is the intersection of two simpler languages. In each part, construct DFAs for the simpler languages, then combine them using the construction discussed in footnote 3 (page 46) to give the state diagram of a DFA for the language given. In all parts, .
ᴬ
ᴬ
Each of the following languages is the complement of a simpler language. In each part, construct a DFA for the simpler language, then use it to give the state diagram of a DFA for the language given. In all parts, .
ᴬ
ᴬ
Give state diagrams of DFAs recognizing the following languages. In all parts, the alphabet is .
The empty set
All strings except the empty string
Give state diagrams of NFAs with the specified number of states recognizing each of the following languages. In all parts, the alphabet is .
ᴬ The language with three states
The language of Exercise 1.6c with five states
The language of Exercise 1.6l with six states
The language with two states
The language with three states
ᴬ The language with three states
The language with one state
The language 0* with one state
Use the construction in the proof of Theorem 1.45 to give the state diagrams of NFAs recognizing the union of the languages described in
Exercises 1.6a and 1.6b.
Exercises 1.6c and 1.6f.
Use the construction in the proof of Theorem 1.47 to give the state diagrams of NFAs recognizing the concatenation of the languages described in
Exercises 1.6g and 1.6i.
Exercises 1.6b and 1.6m.
Use the construction in the proof of Theorem 1.49 to give the state diagrams of NFAs recognizing the star of the languages described in
Exercise 1.6b.
Exercise 1.6j.
Exercise 1.6m.
ᴬ Prove that every NFA can be converted to an equivalent one that has a single accept state.
Let . Give a DFA with five states that recognizes and a regular expression that generates . (Suggestion: Describe more simply.)
Let be the language of all strings over 0,1 that do not contain a pair of 1s that are separated by an odd number of symbols. Give the state diagram of a DFA with five states that recognizes . (You may find it helpful first to find a 4-state NFA for the complement of .)
Show that if is a DFA that recognizes language , swapping the accept and nonaccept states in yields a new DFA recognizing the complement of . Conclude that the class of regular languages is closed under complement.
Show by giving an example that if is an NFA that recognizes language , swapping the accept and nonaccept states in doesn't necessarily yield a new NFA that recognizes the complement of . Is the class of languages recognized by NFAs closed under complement? Explain your answer.
Give a counterexample to show that the following construction fails to prove Theorem 1.49, the closure of the class of regular languages under the star operation. 1 Let recognize . Construct as follows. is supposed to recognize .
Footnotes
-
In other words, you must present a finite automaton, , for which the constructed automaton does not recognize the star of ’s language. ↩
The states of are the states of .
The start state of is the same as the start state of .
. The accept states are the old accept states plus its start state.
Define so that for any and any ,
(Suggestion: Show this construction graphically, as in Figure 1.50.)
Use the construction given in Theorem 1.39 to convert the following two nondeterministic finite automata to equivalent deterministic finite automata.
Give an NFA recognizing the language .
Convert this NFA to an equivalent DFA. Give only the portion of the DFA that is reachable from the start state.
Give regular expressions generating the following languages (cf. Exercise 1.6). In all parts, the alphabet is .
The empty set
All strings except the empty string
(((00)*(11))
a(ba)*b
Use the procedure described in Lemma 1.60 to convert the following finite automata to regular expressions.
In certain programming languages, comments appear between delimiters such as / and /. Let be the language of all valid delimited comment strings. A member of must begin with / and end with / but have no intervening /. For simplicity, assume that the alphabet for is .
Give a DFA that recognizes .
Give a regular expression that generates .
ᴬ Let be any language over the alphabet . Prove that iff .
A finite state transducer (FST) is a type of deterministic finite automaton whose output is a string and not just accept or reject. The following are state diagrams of finite state transducers and .
Each transition of an FST is labeled with two symbols, one designating the input symbol for that transition and the other designating the output symbol. The two symbols are written with a slash, /, separating them. In , the transition from to has input symbol 2 and output symbol 1. Some transitions may have multiple input-output pairs, such as the transition in from to itself. When an FST computes on an input string , it takes the input symbols one by one and, starting at the start state, follows the transitions by matching the input labels with the sequence of symbols . Every time it goes along a transition, it outputs the corresponding output symbol. For example, on input 2212011, machine enters the sequence of states and produces output 1111000. On input abbb, outputs 1011. Give the sequence of states entered and the output produced in each of the following parts.
on input 011
on input 211
on input 121
on input 0202
on input b
on input bbab
on input bbbbbb
on input
Read the informal definition of the finite state transducer given in Exercise 1.24. Give a formal definition of this model, following the pattern in Definition 1.5 (page 35). Assume that an FST has an input alphabet and an output alphabet but not a set of accept states. Include a formal definition of the computation of an FST. (Hint: An FST is a 5-tuple. Its transition function is of the form .)
Exercise 1.24: A finite state transducer (FST) is a type of deterministic finite automaton whose output is a string and not just accept or reject. Each transition of an FST is labeled with two symbols, one designating the input symbol for that transition and the other designating the output symbol, with the two symbols written with a slash, /, separating them. Some transitions may have multiple input-output pairs. When an FST computes on an input string , it takes the input symbols one by one and, starting at the start state, follows the transitions by matching the input labels with the sequence of symbols . Every time it goes along a transition, it outputs the corresponding output symbol.
Using the solution you gave to Exercise 1.25, give a formal description of the machines and depicted in Exercise 1.24.
Read the informal definition of the finite state transducer given in Exercise 1.24. Give the state diagram of an FST with the following behavior. Its input and output alphabets are . Its output string is identical to the input string on the even positions but inverted on the odd positions. For example, on input 0000111 it should output 1010010.
Exercise 1.24: A finite state transducer (FST) is a type of deterministic finite automaton whose output is a string and not just accept or reject. Each transition of an FST is labeled with two symbols, one designating the input symbol for that transition and the other designating the output symbol, with the two symbols written with a slash, /, separating them. Some transitions may have multiple input-output pairs. When an FST computes on an input string , it takes the input symbols one by one and, starting at the start state, follows the transitions by matching the input labels with the sequence of symbols . Every time it goes along a transition, it outputs the corresponding output symbol.
Convert the following regular expressions to NFAs using the procedure given in Theorem 1.54. In all parts, .
Use the pumping lemma to show that the following languages are not regular.
ᴬ
ᴬ (Here, means a string of a's.)
Describe the error in the following "proof" that is not a regular language. (An error must exist because is regular.) The proof is by contradiction. Assume that is regular. Let be the pumping length for given by the pumping lemma. Choose to be the string . You know that is a member of , but Example 1.73 shows that cannot be pumped. Thus you have a contradiction. So is not regular.
For any string , the reverse of , written , is the string in reverse order, . For any language , let . Show that if is regular, so is .
Let
contains all size 3 columns of 0s and 1s. A string of symbols in gives three rows of 0s and 1s. Consider each row to be a binary number and let
For example,
Show that is regular. (Hint: Working with is easier. You may assume the result claimed in Problem 1.31.)
Let
Here, contains all columns of 0s and 1s of height two. A string of symbols in gives two rows of 0 s and 1 s. Consider each row to be a binary number and let
For example, , but . Show that is regular. (You may assume the result claimed in Problem 1.31.)
Let be the same as in Problem 1.33. Consider each row to be a binary number and let
Problem 1.33: contains all columns of 0s and 1s of height two,
A string of symbols in gives two rows of 0s and 1s. For example, , but . Show that is regular.
Let be the same as in Problem 1.33. Consider the top and bottom rows to be strings of 0s and 1s, and let
Problem 1.33: contains all columns of 0s and 1s of height two,
A string of symbols in gives two rows of 0s and 1s. Show that is not regular.
Let . Show that for each , the language is regular.
Let . Show that for each , the language is regular.
An all-NFA is a 5-tuple that accepts if every possible state that could be in after reading input is a state from . Note, in contrast, that an ordinary NFA accepts a string if some state among these possible states is an accept state. Prove that all-NFAs recognize the class of regular languages.
The construction in Theorem 1.54 shows that every GNFA is equivalent to a GNFA with only two states. We can show that an opposite phenomenon occurs for DFAs. Prove that for every , a language exists that is recognized by a DFA with states but not by one with only states.
Recall that string is a prefix of string if a string exists where , and that is a proper prefix of if in addition . In each of the following parts, we define an operation on a language . Show that the class of regular languages is closed under that operation.
ᴬ .
.
For languages and , let the perfect shuffle of and be the language
Show that the class of regular languages is closed under perfect shuffle.
For languages and , let the shuffle of and be the language
Show that the class of regular languages is closed under shuffle.
Let be any language. Define to be the language containing all strings that can be obtained by removing one symbol from a string in . Thus, . Show that the class of regular languages is closed under the DROP-OUT operation. Give both a proof by picture and a more formal proof by construction as in Theorem 1.47.
ᴬ Let and be languages over . Define . Show that the class of regular languages is closed under the operation.
- Let . Show that if is regular and is any language, then is regular.
Prove that the following languages are not regular. You may use the pumping lemma and the closure of the class of regular languages under union, intersection, and complement.
Let and let . Prove that is not regular.
Let and let . Thus because 101 contains a single 01 and a single 10, but because 1010 contains two 10 s and one 01. Show that is a regular language.
Let . Show that is a regular language.
Let . Show that isn't a regular language.
ᴬ Read the informal definition of the finite state transducer given in Exercise 1.24. Prove that no FST can output for every input if the input and output alphabets are .
Exercise 1.24: A finite state transducer (FST) is a type of deterministic finite automaton whose output is a string and not just accept or reject. Each transition of an FST is labeled with two symbols, one designating the input symbol for that transition and the other designating the output symbol, with the two symbols written with a slash, /, separating them. Some transitions may have multiple input-output pairs. When an FST computes on an input string , it takes the input symbols one by one and, starting at the start state, follows the transitions by matching the input labels with the sequence of symbols . Every time it goes along a transition, it outputs the corresponding output symbol.
Let and be strings and let be any language. We say that and are distinguishable by if some string exists whereby exactly one of the strings and is a member of ; otherwise, for every string , we have whenever and we say that and are indistinguishable by . If and are indistinguishable by , we write . Show that is an equivalence relation.
ᴬ Myhill-Nerode theorem. Refer to Problem 1.51. Let be a language and let be a set of strings. Say that is pairwise distinguishable by if every two distinct strings in are distinguishable by . Define the index of to be the maximum number of elements in any set that is pairwise distinguishable by . The index of may be finite or infinite.
Problem 1.51: We say that strings and are distinguishable by if some string exists whereby exactly one of the strings and is a member of ; otherwise, for every string , we have whenever and we say that and are indistinguishable by .
Show that if is recognized by a DFA with states, has index at most .
Show that if the index of is a finite number , it is recognized by a DFA with states.
Conclude that is regular iff it has finite index. Moreover, its index is the size of the smallest DFA recognizing it.
Let and
Show that is not regular.
Consider the language .
Show that is not regular.
Show that acts like a regular language in the pumping lemma. In other words, give a pumping length and demonstrate that satisfies the three conditions of the pumping lemma for this value of .
Explain why parts (a) and (b) do not contradict the pumping lemma.
The pumping lemma says that every regular language has a pumping length , such that every string in the language can be pumped if it has length or more. If is a pumping length for language , so is any length . The minimum pumping length for is the smallest that is a pumping length for . For example, if , the minimum pumping length is 2. The reason is that the string is in and has length 1 yet cannot be pumped; but any string in of length 2 or more contains a 1 and hence can be pumped by dividing it so that , and is the rest. For each of the following languages, give the minimum pumping length and justify your answer.
ᴬ 0001*
ᴬ
ᴬ
(01)*
1011
- If is a set of natural numbers and is a natural number greater than 1, let
Here, we do not allow leading 0s in the representation of a number. For example, and . Give an example of a set for which is regular but is not regular. Prove that your example works.
- If is any language, let be the set of all first halves of strings in so that
Show that if is regular, then so is .
- If is any language, let be the set of all strings in with their middle thirds removed so that
Show that if is regular, then is not necessarily regular.
- Let be a DFA and let be a state of called its "home". A synchronizing sequence for and is a string where for every . (Here we have extended to strings, so that equals the state where ends up when starts at state and reads input .) Say that is synchronizable if it has a synchronizing sequence for some state . Prove that if is a -state synchronizable DFA, then it has a synchronizing sequence of length at most . Can you improve upon this bound?
Let . For each , let be the language consisting of all strings that contain an a exactly places from the right-hand end. Thus . Describe an NFA with states that recognizes in terms of both a state diagram and a formal description.
Consider the languages defined in Problem 1.60. Prove that for each , no DFA can recognize with fewer than states.
Problem 1.60: Let . For each , let be the language consisting of all strings that contain an a exactly places from the right-hand end. Thus .
Let . For each , let be the language consisting of all strings that have at least one a among the last symbols. Thus . Describe a DFA with at most states that recognizes in terms of both a state diagram and a formal description.
Let be an infinite regular language. Prove that can be split into two infinite disjoint regular subsets.
Let and be two languages. Write if and contains infinitely many strings that are not in . Show that if and are two regular languages where , then we can find a regular language where .
Let be an NFA with states that recognizes some language .
Show that if is nonempty, contains some string of length at most .
Show, by giving an example, that part (a) is not necessarily true if you replace both 's by .
Show that if is nonempty, contains some string of length at most .
Show that the bound given in part (c) is nearly tight; that is, for each , demonstrate an NFA recognizing a language where is nonempty and where 's shortest member strings are of length exponential in . Come as close to the bound in (c) as you can.
- Prove that for each , a language exists where
is recognizable by an NFA that has states, and
if , for regular languages , then at least one of the requires a DFA with exponentially many states.
A homomorphism is a function from one alphabet to strings over another alphabet. We can extend to operate on strings by defining , where and each . We further extend to operate on languages by defining , for any language .
Show, by giving a formal construction, that the class of regular languages is closed under homomorphism. In other words, given a DFA that recognizes and a homomorphism , construct a finite automaton that recognizes . Consider the machine that you constructed. Is it a DFA in every case?
Show, by giving an example, that the class of non-regular languages is not closed under homomorphism.
- Let the rotational closure of language be .
Show that for any language , we have .
Show that the class of regular languages is closed under rotational closure.
- In the traditional method for cutting a deck of playing cards, the deck is arbitrarily split two parts, which are exchanged before reassembling the deck. In a more complex cut, called Scarne's cut, the deck is broken into three parts and the middle part in placed first in the reassembly. We'll take Scarne's cut as the inspiration for an operation on languages. For a language , let .
Exhibit a language for which .
Show that the class of regular languages is closed under CUT.
Let . Let .
Show that for each , no DFA can recognize with fewer than states.
Describe a much smaller NFA for , the complement of .
We define the avoids operation for languages and to be avoids . Prove that the class of regular languages is closed under the avoids operation.
Let .
Let . Show that is regular.
Let . Show that is not regular.
Let and be DFAs that have and states, respectively, and then let .
Show that if , then contains some string , where .
Show that if , then excludes some string , where .
Let . Let . Show that is a CFL.