More YES-NO machines

Preview:

DESCRIPTION

δ. More YES-NO machines. (i) The operators δ and (ii) How to “combine” two machines into one (iii) Languages DFAs cannot recognize. current state. symbol. δ :. q. ?. a. δ. jump. ?. δ ( q , a ). state. symbol. next state. The “jump” operator δ. - PowerPoint PPT Presentation

Citation preview

More YES-NO machines

(i) The operators δ and

(ii) How to “combine” two machines into one(iii) Languages DFAs cannot recognize

δ

The “jump” operator δ

qa

δ: ?

δ(q, a)

state symbol

jump? δ

current state symbol

next state

Simply put, given the current state of a DFA and an input symbol, the “delta operator” tells you the next state the machine will “jump” to.

The “journey” operator

q

δ

w1

w2

?

wn

δ

(q, w)

state string

journey?δ

Simply put, given the current state of a DFA and an input string, the “delta-bar operator” tells you the next state the machine will “journey” to.

current state string

destination state

δδ(q,w1)

δ ( δ(q, w1), w2 )

Defining accept / reject using the new operators

Now, we can define “acceptance” of an input string w by a DFA in a simple, concise manner.

start

w1

w2

wn

final

A DFA M = (Q, Σ , δ, s, F ) accepts w є Σ* iff (s, w) = f where f є F.δ

1 2 3 4

aa b b

A B C D

aa b b

1A

ba b

1B 1C 4C 4D

a

. . .

“Combining” two machines into one

Q1

Q2

Q1 x Q2

“Combining” two machines into one

M1 = ( Q1, Σ , δ1, s1, F1 ) M2 = ( Q2, Σ , δ2, s2, F2 )

M = ( Q, Σ , δ, s, F )

Q = Q1 x Q2 = { (q1, q2) | q1 є Q1 and q2 є Q2}

δ( (q1, q2), a ) = ( δ1(q1, a), δ2(q2, a) ),

q1 є Q1, q2 є Q2 and a є Σ

s = ( s1 , s2 )

F = { ( f1 , f2 ) | f1 є F1 or f2 є F2 }

L(M) = L( M1) U L(M2)

a

b

a

ba

final states

b

“Combining” two machines into one: an example

a

b a

a

a b

b

b

L1 = {a x b | x є Σ*}

a

a

b

a

b

b

L2 = {a x | x є Σ*}

L1 = L1 U L2

a

b

How to transform a

machine to do the “opposite” of what it has been doing?

It should be extremely hard to “transform” a machine (or a human being!) to do the “opposite*” of what it has been doing. Shouldn’t it?

But, contrary to what one might expect, it isn’t.

HOW come?

*The “transformed machine” should accept those strings it has been rejecting and vice versa; in other words, it should now recognize the complement of the language recognized by it earlier.

Qfinal states non-final states

The set of states (and everything else) in the “transformed machine” remains the same. Just “rename” the final-states as non-final states and vice-versa.

M = ( Q, Σ , δ, s, F ) M ’ = ( Q, Σ , δ, s, F’ )

w is accepted by M’

F’ = Q \F L(M’) = Σ* \ L( M)

δ(w) є Q\F (F’ = Q \F, the change we introduced)

δ(w) є Set of non-final states of M

w is rejected by M

w є Σ* \ L( M)

δ(w) є F’ (by definition)

How to transform a

machine to do the “opposite” of what it has been doing?

PROOF

----End of proof----

What YES-NO machines can’t doWe give an example of a language that cannot be recognized by any DFA.

Consider L = { anbn | n >= 0 }

We give a “proof by contradiction” for the fact that no DFA can recognize L.

Suppose a DFA M (of course, having finite number of states) recognizes L.

Now consider the set of strings { a, aa, aaa, aaaa, …..} i.e. the set {an | n >=0} which is infinite.

Clearly, the number of strings in this set (which is infinitely many) would outnumber the number of states in the machine (whatever the exact number is!). See illustration (1).

a

aa

aaa … (n times)

aaa … (n + 1 times)

.

.

.

.

.

1

2

n

.

.

.M

(1)

Now, according to the Pigeon-Hole principle (see illustration (2)), there will be two strings ai and aj (i ≠ j) that “land” onto the same state when inputted to the machine (see illustration (3)).

In other words, there will be two strings ai and aj such that (s, ai) = (s, aj), where s is the start state of the machine.

δ δ

What YES-NO machines can’t do

1

2

n

.

.

.M

HOLESa

aa

aaa … (n times)

aaa … (n + 1 times)

.

.

.

.

.

Pigeons

(2)

startstart somesomestatestate

a i

a j (3)

Now consider the strings aibi and ajbi. (Note that these strings have an extra “piece” bi glued to them.) Imagine feeding them (one by one) as inputs to the machine. What states will the machine reach?

Since we already realized that ai and aj (the prefixes of the two new strings) would take the machine to the same state, the machine should end up in the same state (a final or non-final state) for both the inputs aibi (which is in L) and ajbi (which is NOT in L). See illustration (4).

startstart somesomestatestate

a i

a j (4)

bi

Final/Final/Non-finalNon-final

What YES-NO machines can’t do

Thus, the DFA shows the same behaviour for both the inputs (one “valid”, and the other “invalid”), i.e. it either accepts or rejects both—a contradiction. Thus our supposed DFA cannot exist!

What YES-NO machines can’t do

----End of proof----

Recommended