0% found this document useful (0 votes)
36 views10 pages

Homework 6 Template

The document contains homework problems related to formal languages, including the construction of NFAs and DFAs, substring languages, and the intersection and union of languages. It also includes tasks for proving properties of DFAs and constructing Turing machines. Each problem is accompanied by a request for a solution, indicating a focus on theoretical aspects of automata and language theory.

Uploaded by

a56349128
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views10 pages

Homework 6 Template

The document contains homework problems related to formal languages, including the construction of NFAs and DFAs, substring languages, and the intersection and union of languages. It also includes tasks for proving properties of DFAs and constructing Turing machines. Each problem is accompanied by a request for a solution, indicating a focus on theoretical aspects of automata and language theory.

Uploaded by

a56349128
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

250 Homework #6


FirstName LastName
December 4, 2024

General note on diagrams: Some of the the problems ask you to create NFAs and DFAs.
If you are writing your solution using latex, we recommend NOT drawing diagrams using
latex tools. That can take too long to learn. Instead, use some other drawing package to
generate a diagram or even draw it by hand and take a picture of it, and then include the
diagram in the latex using the includegraphics command, as we do in problem 14.5.3 below.

P5.5.6 [10 pts]


If L is any language, we define its substring language Sub(L) to be the set of all strings y
such that y is a substring of any string x ∈ L. Prove that if S is any regular expression, then
Sub(L(S)) is a regular language. Give a recursive algorithm to produce a regular expression
for this language.
Note: This is an exercise in making a structural induction proof, where the inductions use the
rules of how regular languages are constructed. Hint. If L, L1 and L2 are languages with L being
the concatenation of L1 and L2 , and you know Sub(L1 ) and Sub(L2 ) are regular languages, what
is the relationship between Sub(L) and Sub(L1 ) and Sub(L2 ).

Solution:


Collaborated with Nobody.

1
P14.1.3 [10 pts]
Suppose that M1 and M2 are two DFA’s with the same input alphabet. We’ll refer to the
state set, start state, final state set, and transition function of M1 as S1 , ι1 , F1 and δ1
respectively, and similarly for M2 .
We define the product DFA M1 × M2 as follows. The state set is the direct product
S1 × S2 , the set of ordered pairs ⟨s1 , s2 ⟩ with s1 ∈ S1 and S2 ∈ S2 . The start state is the pair
⟨ι1 , ι2 ⟩ and the final state set is (F1 × F2 ). The new transition function takes a state ⟨s1 , s2 ⟩
and a letter a to ⟨δ1 (s1 , a), δ2 (s2 , a)⟩. Prove that the product DFA decides the language
L(M1 ) ∩ L(M2 ).
Note. We mentioned in class that the intersection of two recognizable languages is recognizable.
14.1.3 is the proof of this statement.

Solution:

2
P14.1.4 [5 pts]
Design a variant of the product DFA from Problem 14.1.3 that decides the language L(M1 )∪
L(M2 ). (Hint: You need change only the final state set.)

Solution:

3
P.14.3.6 [10 pts]
Prove that the DFA from Exercise 14.3.6 in the book1 is minimal, either by running the
minimization algorithm on it or by showing that each pair of states is L5 -distinguishable.

Solution:

1
Exercise 14.3.6: Let L5 be the set of binary strings that represent naturals that are divisible by five.
Design a DFA whose language is L5 . (It may help to look at Problem 14.3.3, which gives a DFA for the
similar language L6 .)

4
P14.5.3 [10 pts]
Let the NFA K (Figure 14-16) have alphabet {a, b}, state set {p, q, r} start state p, only
final state r, and transition relation

∆ = {⟨p, a, q⟩, ⟨p, b, q⟩, ⟨p, a, r⟩, ⟨p, b, r⟩, ⟨q, a, p⟩, ⟨q, b, p⟩,
⟨q, a, r⟩, ⟨q, b, r⟩, ⟨r, a, p⟩, ⟨r, b, p⟩, ⟨r, a, q⟩, ⟨r, b, q⟩}.

What is the language L(K)? (Consider the string λ carefully.) How many paths are there
in K from p to r that are labeled by the string aaa? By the string aaaaaaaaaa? By the
string abbabbbaab?

Figure 14.6

Solution:

5
P14.8.1 [10 pts]
Formally prove the correctness of the union construction as follows. Let M1 and M2 be the
two λ-NFA’s constructed for R1 and R2 (so they obey our three assumptions) and let N be
the λ -NFA constructed so that L(N ) = R1 + R2 .
Prove the following by induction on all strings w : If p is any state of N , and ∆∗N (ι, w, p)
is true then either ∆∗M1 (ι1 , w, p) or ∆∗M2 (ι2 , w, p) or both, is true. (We are using the fact that
each state of N is also either a state of M1 or a state of M2 , or both.)

Solution:

6
P14.6.9 parts (a, b, c) only [10 pts]
Given a nonempty finite language S, consider the language CS = Σ∗ SΣ∗ of strings that have
a substring in S.

(a) Describe an ordinary NFA for this language. (Note: The Yes-aba language is just
C{aba} .)

(b) Prove that the minimal DFA for any such language CS has exactly one final state.

(c) Use the Subset Construction to find a DFA for the language CS where S = {aaa, bbb}.
(You may invoke part (b) and not worry about distinguishing the different final states.)

Solution:
(a)

(b)

(c)

7
P14.10.4 [10 pts]
Recall the balanced-parenthesis language Paren from Problems 4.7.6 and 4.7.7, and Section
14.2. Let L3 be the subset of the Paren consisting of all strings that never have a prefix
whose excess of L’s over R’s is greater than 3. Build a DFA for this language, and apply
state elimination to get a regular expression for it.

Note. P 4.7.6 defines Paren as follows:

(a) λ is in Paren.

(b) If u is in Paren,then so is LuR.

(c) If u and v are in Paren, then so is uv.

(d) No other strings are in Paren.

P 4.7.7 States that Paren is equivalently the language characterized by the following two
properties. A string w ∈ {L, R}∗ is in Paren if and only if

(1) The number of L’s and R′ s in the string is equal

2) In any prefix of the string, the number of L’s is at least as great as the number of R’s.

You should use the minimal DFA for this language, which has five states. Then you’re
asked to create a regular expression from this DFA, using the state elimination algorithm
from lecture.

Solution:

8
EC: P14.10.5 [10 pts]
Build successively a λ-NFA, an NFA, a DFA, and a minimal DFA from the regular expression
in Problem 14.10.4.
You may simplify the λ-NFA a bit from your regular expression before the using the
construction to make an ordinary NFA.. In particular, there are states that have one edge in
and one edge out, and you may eliminate the state and merge the two edges into one. With
this simplification, the λ-NFA should have nine nodes, six letter moves, and eight lambda-
moves.

Solution:

9
EC: P15.6.2 [10 pts]
Build a Turing machine Mcopy that when started on input w, (i.e., in configuration ι□w),
halts with the tape contents □w□w. You need not give the entire state table as long as your
description is clear and complete. Let Σ = {a, b}.
Note: When designing a Turing machine to perform some task, your first priority should be
clarity. The grader needs to know that your machine is correct for all possible inputs, and it is not
the grader’s job to test it. The burden of proof is on you. We don’t care much about how efficient
your machine is, or what resources it uses, as long as we can see that it is correct. In particular,
you are allowed to use any number of states and any tape alphabet size, as long as these parameters
are both constants with respect to the input size. A useful convention is that if you don’t indicate
what a state would do with a particular tape letter, assume that is will halt and reject.

Solution:

10

You might also like