+ All Categories
Home > Documents > CSCI 2670 Introduction to Theory of Computing September 13.

CSCI 2670 Introduction to Theory of Computing September 13.

Date post: 21-Jan-2016
Category:
Upload: annabelle-carpenter
View: 226 times
Download: 0 times
Share this document with a friend
30
CSCI 2670 Introduction to Theory of Computing September 13
Transcript
Page 1: CSCI 2670 Introduction to Theory of Computing September 13.

CSCI 2670Introduction to Theory of

Computing

September 13

Page 2: CSCI 2670 Introduction to Theory of Computing September 13.

Agenda

• Last class– Example DFA construction (on board)– Equivalence of RE’s and regular

languages– GNFA’s

• Today– More on equivalence of RE’s and regular

languages– Non-regular languages?

• Tomorrow– Dr. Canfield returns

Page 3: CSCI 2670 Introduction to Theory of Computing September 13.

RE’s and regular languages

Theorem: A language is regular if and only if some regular expression describes it.– i.e., every regular expression has a

corresponding DFA and vice versa

Page 4: CSCI 2670 Introduction to Theory of Computing September 13.

GNFA’s

• To prove every DFA can be described using an RE, we introduce GNFA’s

• A GNFA is an NFA with the following properties:

1. The start state has transition arrows going to every other state, but no arrows coming in from any other state

2. There is exactly one accept state and there is an arrow from every other state to this state, but no arrows to any other state from the accept state

3. The start state is not the accept state

Page 5: CSCI 2670 Introduction to Theory of Computing September 13.

GNFA’s (continued)

4. Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself

5. Instead of being labeled with symbols from the alphabet, transitions are labeled with regular expressions

Page 6: CSCI 2670 Introduction to Theory of Computing September 13.

Equivalence of DFA’s and RE’s

• First show every DFA can be converted into a GNFA that accepts the same language

• Then show that any GNFA has a corresponding RE that accepts the same language

Page 7: CSCI 2670 Introduction to Theory of Computing September 13.

Converting a DFA to a GNFA

Add two new states

ε εqs qt

1

1

0

0

q1

q2

q3 q40,1

0,1

Page 8: CSCI 2670 Introduction to Theory of Computing September 13.

Converting a DFA to a GNFA

ε εqs qt

1

1

0

0

q1

q2

q3 q40,1

0,1

• All transition labels with multiple labels are relabeled with the union of the previous labels

01

01

Page 9: CSCI 2670 Introduction to Theory of Computing September 13.

Converting a DFA to a GNFA

ε εqs qt

1

1

0

0

q1

q2

q3 q4

• All pairs of states without transitions get a transition labeled

01

01

Page 10: CSCI 2670 Introduction to Theory of Computing September 13.

Converting a DFA to a GNFA

ε εqs qt

1

1

0

0

q1

q2

q3 q4

• The resulting state diagram is a GNFA– All GNFA properties are satisfied

01

01

Page 11: CSCI 2670 Introduction to Theory of Computing September 13.

Converting a DFA to a GNFA

ε εqs qt

1

1

0

0

q1

q2

q3 q4

• No step changed the strings accepted by the machine

01

01

Page 12: CSCI 2670 Introduction to Theory of Computing September 13.

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

Page 13: CSCI 2670 Introduction to Theory of Computing September 13.

Removing one state from a GNFA

q1’ q2’

a13

a32

a12

a33

q2q1

q3

a12a13a33*a3

2

Page 14: CSCI 2670 Introduction to Theory of Computing September 13.

Accounting for loops

a11a13a33*a3

1

q1’ q2’

a31

a13 a32

a23

a21

a12

a33

a22

q2q1

q3

a11

a22a23a33*a32

a21a23a33*a3

1

a12a13a33*a3

2

Page 15: CSCI 2670 Introduction to Theory of Computing September 13.

Every DFA has a corresponding RE

Proof: Let M be any DFA and let w be any string in Σ*. Convert M to G, a GNFA, then convert G to R, a regular expression, using methods shown in class.

Want to show wL(M) iff wL(R).

First show wL(M) iff wL(G). Then show wL(G) iff wL(R).

Page 16: CSCI 2670 Introduction to Theory of Computing September 13.

wL(M) iff wL(G)

• Let w = w1w2…wn, where each wi Σ.• w L(M)• iff there is a sequence of states q1, q2,

…, qn+1 such that• q1 = q0

• qn+1F• qi+1 = (qi,wi) for each i = 1, 2, …, n

• iff when w is read by G, the sequence of states qs, q1, q2, …, qn+1, qt would accept w

• iff wL(G)

Page 17: CSCI 2670 Introduction to Theory of Computing September 13.

wL(G) iff wL(R)

• Prove by induction on number of states in G

Base case: If G has 2 states then clearly wL(G) iff wL(R).

Induction step: Assume wL(G) iff wL(R) for every G with k-1 states. Prove w L(G) iff wL(R) for every G with k states.

Page 18: CSCI 2670 Introduction to Theory of Computing September 13.

wL(R) if wL(G)

Assume wL(G) and an accepting branch of the computation G enters on w is qs, q1, q2, …, qt. Let G’ be the GNFA that results from removing one of G’s states, qrip. There are two possibilities:

Case 1: qrip is never entered in the computation of w.Then the same branch of computation exists in G’.

Page 19: CSCI 2670 Introduction to Theory of Computing September 13.

wL(R) if wL(G)

Assume wL(G) and an accepting branch of the computation G enters on w is qs, q1, q2, …, qt. Let G’ be the GNFA that results from removing one of G’s states, qrip. There are two possibilities:

Case 2: qrip is entered in the computation of w (bracketed byqi and qj).

Then the new transition between qi and qj in G’ describes the computation that could be done on the computation of w through the branch qi, qrip, qj.

So G’ accepts w. By induction wL(R).

Page 20: CSCI 2670 Introduction to Theory of Computing September 13.

wL(G) if wL(R)

Assume wL(R). By induction hypothesis, wL(G’), the k-1 state GNFA resulting from removing one state from G. By construction, any computation in G’ can also be done in G – possibly going through an extra state qrip. Therefore, wL(G).

Page 21: CSCI 2670 Introduction to Theory of Computing September 13.

Example

1

q1 q2

1

0

0

Page 22: CSCI 2670 Introduction to Theory of Computing September 13.

Example

1

q1 q2

1

0

0

qs qt

Step 1: Add two new states

ε ε

Page 23: CSCI 2670 Introduction to Theory of Computing September 13.

Example

1

q1 q2

1

0

0

qs qt

Step 2: Remove q1

ε

1*0

101*0

ε

Page 24: CSCI 2670 Introduction to Theory of Computing September 13.

Example

q2

qs qt

Step 3: Remove q2

1*0

101*0

ε

1*0(101*0)*

Page 25: CSCI 2670 Introduction to Theory of Computing September 13.

Example

1

q1 q2

1

0

0

So this DFA

Is equivalent to the regular expression 1*0(101*0)*

Page 26: CSCI 2670 Introduction to Theory of Computing September 13.

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,1010010001,…}– {w | w has the same number of 0s and

1s}

• How can we tell if a language is not regular?

Page 27: CSCI 2670 Introduction to Theory of Computing September 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

Page 28: CSCI 2670 Introduction to Theory of Computing September 13.

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

1. for each i 0, xyiz is in A2. |y| > 0, and3. |xy| p

p is called the pumping length

Page 29: CSCI 2670 Introduction to Theory of Computing September 13.

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

Page 30: CSCI 2670 Introduction to Theory of Computing September 13.

Proof idea

1. for each i 0, xyiz is in A2. |y| > 0, and3. |xy| p

x

y

z


Recommended