Computer Science 500 Theory of Computation Spring, 2000 - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Computer Science 500 Theory of Computation Spring, 2000

Description:

AR is not regular by the pumping lemma (exercise or see the solns. to test 1, fall 98) ... Let a,b,c be any decomposition of w s.t. w=abc, |b| 1, |ab| n ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 25
Provided by: peterg2
Category:

less

Transcript and Presenter's Notes

Title: Computer Science 500 Theory of Computation Spring, 2000


1
Computer Science 500Theory of ComputationSpring,
2000 January 31
Sample Regular Language Questions
2
the Pumping Lemma in contrapositive form.
n in Z w such that w gt n x,y,z such that w
xyz and ygt0 and xyltn igt0, xyiz is NOT in L
A
If
E
A
E
L is NOT a regular language
Then
3
NFA to regular expressionexample
Problem 1
Use the NFA to reg.exp. conversion technique to
get a regular expression that represents the
language L all binary strings with a number
of 1s equal to 2 mod 3
4
Problem 2 (hint use the GNFA to regular
expression conversion if you like) Write down a
regular expression for the language of binary
strings containing an even number of 0s.
0
acc
1
1
0
acc
1 U 010
R (1 U 010)
5
P. 3 Write down a regular expression for the
language of binary strings containing both an
even number of 0s and an even number of 1s.
0
acc
0
1
1
1
1
0
0
6
11
0
0
acc
acc
0
0
1
1
1
1
1
1
01
10
0
0
00
7
11
0(11)0
0
acc
acc
1 U 10(11)0
0
1
1 U 0(11)10
1
01
10
00
00 U 01(11)10
8
0(11)0
0(11)0 U ((1 U 0(11)10)(00 U 01(11)10)(1 U
10(11)0))
acc
1 U 10(11)0
acc
1 U 0(11)10
R (0(11)0 U ((1 U 0(11)10)(00 U
01(11)10)(1 U 10(11)0)))
00 U 01(11)10
9
Problem 4 (True or False) a) The NFA to DFA
transformation presented in class takes an NFA
of n states and produces a DFA of O(n2)
states. False Our transformation uses the
power set of the NFAs states -- a set of size
2n. b) The primary reason we study to DFAs is
because they are our best abstract model for real
computers. False Turing Machines are our best
abstract model for real computers. c) The
language L all binary strings with an odd
number of 0s and a number of 1s equal to 3 mod
4 is regular. True Let L1 all binary
strings with an odd number of 0s and L2 all
binary strings with a number of 1s equal to 3
mod 4. Then L L1 intersect L2 L1 and L2 are
regular and the intersection of two regular sets
is regular.
10
d) The language L xx x a binary string is
a regular language. False e) The regular
expressions (?10 U 0) and 0? represent the
same binary languages. True (?10 U 0) (??U
0) 0 0?
11
Problem 5 a) write an NFA state diagram for an
NFA that accepts the language represented by
(00)U(01)
10pts
0
0,1
acc
1
?
0
1
?
1
0
0
acc
1
12
b) write a DFA state diagram for a DFA that
accepts the language represented by (00)U(01)
15pts
0
0
0,1
acc
1
0
0
1
1
1
acc
1
1
0
0
acc
1
13
Problem 6
Draw the state diagrams for NFAs that accept the
following languages a) L all binary
strings with a number of 1s equal to 3 mod 4 and
a number of 0s equal to 1 mod 3 b) L
all binary strings with a number of 1s equal to
2 mod 3 or a number of 0s equal to 1 mod 2
0
start
1
14
Problem 7
A) Every regular language is a finite set False
consider 1 B) Every finite language is a
regular language True C) If L1 is regular and L2
is regular, then L1 intersect L2
is regular True D) If L is regular and L L1 U
L2, then L1 and L2 are regular False Consider
0,1 0,1 U E) a constant cgt1 such
that regular languages L,
integer k, NFA N with k states that
accepts L DFAs D that accepts L, has at
least cn states. False There are languages for
which non-determinism does not help at all. For
example, if LS, then the smallest NFA or DFA
that accepts this language has one state.
E
A
E
E
A
15
8) Draw state diagrams of NFAs that accept the
following languages (note that here, you do not
need to include transitions that cause the NFA to
reject) a) w w ends with 00 with 3 states b)
0100 with 3 states c) 0 with one state
1
?
0
B
?
?
A
s
A
?
0
s
A
0,1
s,a
C
0
16
Problem 9
For any language L, we define LR w wR ? L
(By wR, we mean a string with the same
characters as w, but in reverse order) Prove
if L is regular, then LR is regular
17
Problem 10 -- (slightly) tricky
Show that L is not regular L 0n1p n ? Z, p
any prime number? 1
18
Claim L can be pumped
Let n 2 Then for all w in L where w gt2 if w
1j, let x ?, y 1 z 1j-1 if w 0k1p let x
?, y 0, z 0k-11p in either case, for all i gt
0, xyiz is in L
19
Claim L is not regular
Proof B, B are regular L A U B A 001p
p prime B 1, B 0,100,1 A L
intersect B AR is not regular by the pumping
lemma (exercise or see the solns to test 1, fall
98)
20
Problem 11
Let L be any regular language and define the
language FL(L) xz there exists y, x y
z and xyz is in L ie FL(L) is composed of the
first and last thirds of strings of L that are of
length 0 mod Is FL(L) always regular? Prove
your answer correct. No. Consider L represented
by (10)1
21
We will show that FL(L) is not regular by
invoking the contrapositive of the pumping
lemma. Let n be any integer Let w (10)n11(01)n
Note that w is in FL(L) because
(10)n1(01)n01(01)n is in L Let a,b,c be any
decomposition of w s.t. wabc, bgt1, abltn Note
ab2c has two consecutive 1s appearing in the 2nd
half of the string Therefore, there is no string
y such that yxz where xz ab2c and xyz
is in L. Therefore ab2cxz is not in FL(L) and
hence FL(L) is not regular.
22
Optional Homework
1. Write an algorithm that converts any DFA into
the regular expression that it computes.
Convert your algorithm into a program if you have
any doubt about its correctness.
23
2. Prove that the following binary languages are
not regular a) L w exists x where HW(w)
is 5x b) L all binary strings of the form
xxR where xR is the string x with bits
appearing in reverse order
24
3. Prove or disprove the following statements
about regular languages. A) If A is a regular
language and B is a subset of A, then B must be a
regular language B) If A is a regular language
and B is a superset of A, then B must be a
regular language
Write a Comment
User Comments (0)
About PowerShow.com