You are on page 1of 11

Running head: INTRO TO THEORETICAL COMPUTER SCIENCE 1

Intro to Theoretical Computer Science

Author

Author Affiliation
INTRO TO THEORETICAL COMPUTER SCIENCE 2

CSE 355: Intro to Theoretical Computer Science (Fall 2018)

Instructor: Troy McDaniel

Homework Assignment #2: Regular Expressions and Nonregular Languages

This assignment is worth 100 points and 20% of your final grade. There are five problems total, each with

one or more parts. It is due Tuesday, Sep 18th at the start of class. Please hand-in directly to your

instructor; do not email. Your answers may be typed or handwritten.

1. Let  0,1. For each part below, write the formal description of the set described by the regular

expression. 20 points

a) 0  1* 00 0  1* 11 0 1*

String contains at least three 1s


b) 1*  01   0 *  

All strings containing an even number of 0's:

c) 01  

All binary strings except empty string


d) *  

String with only 0s

2. Let  0,1. For each part below, write the regular expression that describes the set. 20 points
INTRO TO THEORETICAL COMPUTER SCIENCE 3

a) L1  w | w starts with 0 and is of odd length or ends with 1 and length is a multiple of three

(² ∪ 1) ∪ (0 ∪ 10 ∪ 110 ∪ 1110 ∪ 1111)(0 ∪ 1)∗

b) L2  w | w is any string except 00, 11, 100, and 101

c) L3  {xy | x is an odd number of 1s and y is an even number of 0s and xy  3}

0(00 ∪ 01 ∪ 10 ∪ 11)∗ ∪ 1((00 ∪ 01 ∪ 10 ∪ 11)∗ (0 ∪ 1)).

d) L4  w | w is any string except the empty string

(0|1)(0|1)*

3. Use the GNFA method discussed in class to convert the following DFA into an equivalent regular

expression. You must show all steps to receive full credit. 20 points

Continue until each DFA state has a 0-edge and a 1-edge leaving it. DFA accept states have ≥ 1

accept states from N

Given NFA N = (Q, Σ, δ, q0, F), build an equivalent DFA


INTRO TO THEORETICAL COMPUTER SCIENCE 4
INTRO TO THEORETICAL COMPUTER SCIENCE 5

4. Let  0,1. Use the procedure given in Lemma 1.55 to convert the regular expression below into

an NFA. You must show all steps to receive full credit. 20 points

0* 0  1*1 * 0101* 


INTRO TO THEORETICAL COMPUTER SCIENCE 6

5. For each part, show that the language is regular, or use the pumping lemma to show that the language is

nonregular. You must justify your answers to receive full credit. 20 points

a) L5  w0w R
| w 0,1*  where s R
is the reverse of string s
INTRO TO THEORETICAL COMPUTER SCIENCE 7

Expect by contradiction that L is regular. At that point, by PL, we realize that there

exists a pumping length p > 0 to such an extent that any word w ∈ L, |w| ≥ p can be

apportioned as xyz = w (with |xy| ≤ p and |y| > 0) so that, for any I ≥ 0, the word xyi z

likewise has a place with L. Notice that achieving a contradiction might be precarious for this

situation, since it's insufficient to demonstrate that there exists a segment xyz = w to such an

extent that w can't be "pumped" (review that by "pumping a word w = xyz" we mean

considering expressions of the shape xyi z for I ≥ 0). Rather, we have to show a word w ∈ L

to such an extent that, any conceivable parcel xyz = w, w can't be pumped without dropping

out dialect L. Most selections of words don't work since they can be pumped. Mystically,

(ideally, before the finish of the issue you'll see why) we utilize the word 0 p1 p+p! , where p!

= p • (p − 1)• • 2 • 1. Plainly|w| ≥ p. Also, any parcel of w into xyz must be to such an extent

that y involves just 0 s (since |xy| ≤ p). At that point, the reality of the situation must prove

that y = 0 k for some k 0 < k ≤ p (since |y| > 0). Presently, we consider the word w 0 = xyi z,

for some I ≥ 0 which we leave unspecified for the time being.

The word w 0 equals xyi z = 0 p+(i−1)k1 p+p! . We need to demonstrate that for any

estimation of k (that is, any conceivable y and in this way, any conceivable parcel) there exists

an estimation of I ≥ 0 which makes w 0 have a similar number of 0 s and 1 0 s: n = p + (I −

1)k = p + p! = m. This repudiates the condition n 6= m for words in L. To be sure, by

comprehending p + (I − 1)k = p + p! we get I = p! k + 1. In this way, for any estimation of k

(review that 0 < k ≤ p) p! k + 1 will be a positive whole number and subsequently, there exists

an esteem I ≥ 0 (to be specific I = p! k + 1) with the end goal that w 0 6∈ L. By the by, by PL,

w 0 ∈ L. We have a contradiction.
INTRO TO THEORETICAL COMPUTER SCIENCE 8

.L6  0n3
|n0 
By contradiction, assume L is regular. Then L is additionally regular. Let’s see

however L appearance like: L is that the language of all the words that either (a) square

measure of the shape a n b m, wherever n = m, or (b) contain the substring ba (which isn't

allowed in L). Therefore, L = zero } ∪ . And thus, L \ = zero } . The left facet of the last

expression is regular as a result of the set-minus operation is regular (recall that A \ B = A ∩

B). However, the proper hand facet isn't. We’ve got a contradictionL7  02n | n  0

Let the length of this half be letter s.t. 0 ≤ q ≤ p. By Clause 1 of the Pumping

Lemma: ∀k ∈ N, ∃n ∈ N s.t. a pair of n = a pair of p + kq allow us to contemplate the case

wherever k = one. By the Pumping Lemma, there should be AN n s.t. 2 n = 2 p + q where 0

&lt; q ≤ p. Now we know that for ∀m ∈ N, a pair of m + m &lt; a pair of m+1 . Since letter

&lt; p, it follows that a pair of p + letter &lt; a pair of p+1 . therefore it's impossible that the

string we have a tendency to get by one spherical of pumping be a member of A3. That is,

there's a ”long enough” string in A3 that can't be tense. therefore A3 isn't regular. In general,

languages that involve over ”linear” growth area unit ne'er regular

b) L6  0n3 | n  0

By contradiction, expect L is regular. At that point L is additionally regular. We should

perceive what L looks like: L is the dialect of the considerable number of words that either

(an) are of the frame a n b m, where n = m, or (b) contain the substring ba (which isn't

permitted in L). Subsequently, L = { a n b n : n ≥ 0 } ∪ { w : w = (a ∪ b) ∗ ba(a ∪ b) ∗ }.

What's more, subsequently, L \ { w : w = (a ∪ b) ∗ ba(a ∪ b) ∗ } = { a n b n : n ≥ 0 } . The left


INTRO TO THEORETICAL COMPUTER SCIENCE 9

hand side of the last articulation is regular on the grounds that the set-short activity is regular

(review that A \ B = A ∩ B). Nonetheless, the correct hand side isn't. We have a contradiction

c) L7  02n | n  0

Give the length of this section a chance to be q s.t. 0 ≤ q ≤ p. By Clause 1 of the Pumping

Lemma: ∀k ∈ N, ∃n ∈ N s.t. 2 n = 2 p + kq Let us consider the situation where k = 1. By the

Pumping Lemma, there must be a n s.t. 2 n = 2 p + q where 0 < q ≤ p. Presently we realize that

for ∀m ∈ N, 2 m + m < 2 m+1 . Since q < p, it takes after that 2 p + q < 2 p+1 . Subsequently it

isn't conceivable that the string we get by one round of pumping be an individual from A3. That

is, there is a "sufficiently long" string in A3 that can't be pumped. Henceforth A3 isn't regular.

By and large, dialects that include more than "direct" development are never regular

d) L8  01ij 0k | i  j  k and i , j , k  0

Review that a word w is palindrome if w = w R, where w R is the word framed by

turning around the images in w (eg. on the off chance that w = 010111, at that point w R =

111010). For instance w = 0100110010 is palindrome. As usual, we demonstrate it by

contradiction. Expect L is regular. At that point the dialect supplement of L, say L 0 = L = {w | w

∈ {0, 1} ∗ is palindrome } is likewise regular. In the event that L 0 is regular, at that point by

pumping lemma, there exits an integer p > 0 (the pumping length) to such an extent that any

word w ∈ L 0 , |w| ≥ p can be divided as xyz = w (with |xy| ≤ p and |y| > 0) so that, for any I ≥ 0,

the word xyi z likewise has a place with L 0 . In any case, consider the word w = 0 p10p .

Obviously, |w| = 2p + 1 so it fulfills the condition |w| ≥ p of the hypothesis. In any case, any

substantial segment of w into words x, y, z (legitimate as in w = xyz, |y| > 0, and |xy| ≤ p) must

be with the end goal that y = 0 k for some integer k > 0, (since |xy| ≤ p, string y can't contain the
INTRO TO THEORETICAL COMPUTER SCIENCE 10

center 1) and after that x = 0 p−k , and z = 10p . In the event that we shape the word w 0 = xy0 z

(that is, take I = 0). at that point w 0 = 0 p−k ²10p = 0 p−k10p which can't be palindrome since p

− k < p. Consequently, w 0 6∈ L 0 , which repudiates the consequence of the pumping lemma.


INTRO TO THEORETICAL COMPUTER SCIENCE 11

Reference List

Mayer, J., Borges, P. V., & Simske, S. J. (2018). Introduction. In Fundamentals and Applications

of Hardcopy Communication (pp. 1-5). Springer, Cham.

You might also like