Download presentation
Presentation is loading. Please wait.
1
CSCI 2670 Introduction to Theory of Computing
September 9, 2004
2
Agenda Yesterday Today Proved correspondence between DFA’s and RE’s
Began an example converting a DFA to an RE Today Complete example Learn how to prove languages are not regular
3
Next week New method for describing languages Context-free grammars
Read Section 2.1 (pages 91 – 101)
4
Converting a GNFA to a RE
If the GNFA has two states, then the label connecting the states is the RE Otherwise, remove one state at a time without changing the language accepted by the machine until the GNFA has two states
5
Removing one state from a GNFA
q2 q1 q3 a12a13a33*a32 q1’ q2’
6
Accounting for loops a22a23a33*a32 a11a13a33*a31 a12a13a33*a32 q1’
7
Example 1 q1 q2
8
Example 1 1 q1 q2 ε ε qs qt Step 1: Add two new states
9
Example 101*0 1 1 q1 q2 ε ε qs qt 1*0 Step 2: Remove q1
10
Example 101*0 q2 ε qs qt 1*0 1*0(101*0)* Step 3: Remove q2
11
Example So this DFA 1 q1 q2 Is equivalent to the regular expression 1*0(101*0)*
12
Nonregular languages So far, we have explored several ways to identify regular languages DFA’s, NFA’s, GNFA’s, RE’s There are many nonregular languages {0n1n | n 0} {101,101001, ,…} {w | w has the same number of 0s and 1s} How can we tell if a language is not regular?
13
Property of regular languages
All regular languages can be generated by finite automata States must be reused if the length of a string is greater than the number of states If states are reused, there will be repetition
14
The pumping lemma Theorem: If A is a regular language, then there is a number p where, if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions for each i 0, xyiz is in A |y| > 0, and |xy| p p is called the pumping length
15
Proof idea Pumping length is equal to the number of states in the DFA whose language is A p = |Q| If A accepts a word w with |w| > p, then some state must be entered twice while processing w Pigeonhole principle
16
Proof idea x y z for each i 0, xyiz is in A |y| > 0, and |xy| p
17
Using the pumping lemma
We can use the pumping lemma to prove a language B is not regular Assume B is regular Show that the pumping lemma is not satisfied Proof by contradiction
18
Example B={101,101001, ,…} The jth and (j+1)th 1’s are separated by j 0’s Assume B is regular and let w be any string in B Let w=xyz, where |y|>0 We cannot make any assumptions on the value of p We want to show that no matter what y is, there is some i for which xyizB
19
Example (cont.) There are 3 possibilities for y If y=0b then xy2z B
y has no 1’s y = 0b for some b > 0 y has one 1 y = 0b10c for some b,c 0 y has two or more 1’s y = 0b10c1v for some b,c 0 and some v* If y=0b then xy2z B The number of 1’s between the last 1 in x and the fist 1 in z has increased
20
Example (cont.) There are 3 possibilities for y
y has no 1’s y = 0b for some b > 0 y has one 1 y = 0b10c for some b,c 0 y has two or more 1’s y = 0b10c1v for some b,c 0 and some v* If y = 0b10c then xy3z B There are two consecutive 1’s with b+c 0’s between them
21
Example (cont.) There are 3 possibilities for y
y has no 1’s y = 0b for some b > 0 y has one 1 y = 0b10c for some b,c 0 y has two or more 1’s y = 0b10c1v for some b,c 0 and some v* If y=0b10c1v then xy2z B There are c 0’s between a pair of consecutive 1’s twice
22
Example (cont.) Therefore, the pumping lemma is not satisfied so B is not a regular language For every p and every y with |y| > 0, we can show that xyiz B for some i
23
Have an excellent weekend
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.