You are on page 1of 55

Theory of Computation

Deterministic Finite Automata Barath Raghavan


CS 361 Fall 2009 Williams College

Tuesday, September 15, 2009

MISC
Anonymous feedback Homework 1 LaTeX
Tuesday, September 15, 2009

Claim: In any set of n hats, all are the same color. Proof by induction: Base case: If n = 1, all hats are the same color. Inductive case: Assume that the claim holds for all n ! k. Examine any set of n = k+1 hats. Remove one hat from the set; the remaining set has k hats and thus is of a single color. Replace the hat and remove a different hat from the set; the resulting set has k hats and thus is of a single color. The two sets overlap, thus they must be of the same color. Therefore, all k+1 hats are the same color.

Tuesday, September 15, 2009

Claim: In any set of n hats, all are the same color. Proof by induction: Base case: If n = 1, all hats are the same color. Inductive case: Assume that the claim holds for all n ! k. Examine any set of n = k+1 hats. Remove one hat from the set; the remaining set has k hats and thus is of a single color. Replace the hat and remove a different hat from the set; the resulting set has k hats and thus is of a single color. The two sets overlap, thus they must be of the same color. Therefore, all k+1 hats are the same color.

Tuesday, September 15, 2009

Deterministic

Finite
Automata
Tuesday, September 15, 2009

Tuesday, September 15, 2009

An organism or an automaton receives stimuli via its sensory receptor organs, and performs actions via its effector organs. To say that certain actions are a response to certain stimuli means, in the simplest case, that the actions are performed when and only when those stimuli occur... So we ask what kind of events are capable of being represented in the state of an automaton. -- Kleene, Representation of events in nerve nets and nite automata (1956)

Tuesday, September 15, 2009

Tuesday, September 15, 2009

1 1 2, 3 1

2 2 3

3 3

1, 2

Elevator Automaton
Tuesday, September 15, 2009

States Alphabet Transition Start state Final states


Tuesday, September 15, 2009

set of states

Tuesday, September 15, 2009

set of states the alphabet

Tuesday, September 15, 2009

set of states the alphabet transition function

:QQ

Tuesday, September 15, 2009

set of states the alphabet transition function

:QQ
q0 Q

start state

Tuesday, September 15, 2009

set of states the alphabet transition function

:QQ
q0 Q F Q

start state set of nal states

Tuesday, September 15, 2009

1 1 2, 3 1

2 2 3

3 3

1, 2

Tuesday, September 15, 2009

1 1 2, 3 1

2 2 3

3 3

1, 2

1, 2, 3} Q = {

Tuesday, September 15, 2009

1 1 2, 3 1

2 2 3

3 3

1, 2

1, 2, 3} Q = {

= {1, 2, 3}

Tuesday, September 15, 2009

1 1 2, 3 1

2 2 3

3 3

1, 2

Tuesday, September 15, 2009

= {1, 2, 3} 3} 1 F = { q0 =

1, 2, 3} Q = {

1 1 2, 3 1

2 2 3

3 3

1, 2

States

Tuesday, September 15, 2009

1 2 3

1 1 1 2

2 2 2 2

3 2 3 3

Inputs

What languages do these automata recognize?

Tuesday, September 15, 2009

0, 1 A 0, 1 B

Tuesday, September 15, 2009

0, 1 A 0, 1 B

L = { }
Tuesday, September 15, 2009

0 A 1

0 B 1

0 C 1

0, 1 D

Tuesday, September 15, 2009

0 A 1

0 B 1

0 C 1

0, 1 D

L = {w | w contains at least 3 1s}


Tuesday, September 15, 2009

?
Tuesday, September 15, 2009

0 A 1 0
a) b) c) d)

1 B 1 C 0

0, 1 D

L = {w | w contains at most two 1s} L = {w | |w| < 3}


L = {w | |w| < 3 or contains at least two 1s}

L = {w | w doesnt contain 110}

Tuesday, September 15, 2009

0 A 1 0 B 1

1 C 0

0, 1 D

L = {w | w doesnt contain 110}


Tuesday, September 15, 2009

0 A 1 0
a) b) c) d)

1 B 1 C 0

0, 1 D

L = {w | w contains at most two 1s} L = {w | |w| < 3}


L = {w | |w| < 3 or contains at least two 1s}

L = {w | w doesnt contain 110}

Tuesday, September 15, 2009

0 A 1 0
a) b) c) d)

1 B 1 C 0

0, 1 D

L = {w | w contains at most two 1s} L = {w | |w| < 3}


L = {w | |w| < 3 or contains at least two 1s}

L = {w | w doesnt contain 110}

Tuesday, September 15, 2009

0 A 1 0
a) b) c) d)

1 B 1 C 0

0, 1 D

L = {w | w contains at most two 1s} L = {w | |w| < 3}


L = {w | |w| < 3 or contains at least two 1s}

L = {w | w doesnt contain 110}

Tuesday, September 15, 2009

0 A 1 0
a) b) c) d)

1 B 1 C 0

0, 1 D

L = {w | w contains at most two 1s} L = {w | |w| < 3}


L = {w | |w| < 3 or contains at least two 1s}

L = {w | w doesnt contain 110}

Tuesday, September 15, 2009

What automata recognize these languages?

Tuesday, September 15, 2009

L = {w | |w| is odd and begins with 0 or is even and begins with 1}

Tuesday, September 15, 2009

A 1 C

0 0, 1 0, 1

L = {w | |w| is odd and begins with 0 or is even and begins with 1}


Tuesday, September 15, 2009

L = {w | w = or every odd position of w is a 1}

Tuesday, September 15, 2009

1 A 0 C 0, 1
L = {w | w = or every odd position of w is a 1}
Tuesday, September 15, 2009

0, 1

?
Tuesday, September 15, 2009

L = {w | w is not the string 11 or 111}

Tuesday, September 15, 2009

1 0

B 0

1 0 E

1 0, 1

0, 1

L = {w | w is not the string 11 or 111}


Tuesday, September 15, 2009

Denition
1. A language L is regular if some DFA recognizes it. 2. The language L(A) recognized by a DFA A is regular.
Tuesday, September 15, 2009

L1 = {w | |w| is odd and begins with 0 or is even and begins with 1}


L2 = {w | w = or every odd position of w is a 1}
Can we build an automaton that accepts:

L3 = L1 L2
Tuesday, September 15, 2009

A1 1 C1
A2 0 C2 0, 1
Tuesday, September 15, 2009

0 0, 1

B1
L1 = {w | |w| is odd and begins with 0 or is even and begins with 1 } 0, 1

1 0, 1 B2

L2 = {w | w = or every odd position of w is a 1}

L3 = L1 L2

How can we combine two DFAs?

Tuesday, September 15, 2009

Q = {(r1 , r2 ) | r1 Q1 and r2 Q2 }

Tuesday, September 15, 2009

Q = {(r1 , r2 ) | r1 Q1 and r2 Q2 }

= 1 2

Tuesday, September 15, 2009

Q = {(r1 , r2 ) | r1 Q1 and r2 Q2 } ((r1 , r2 ), a) = (1 (r1 , a), 2 (r2 , a))

= 1 2

Tuesday, September 15, 2009

Q = {(r1 , r2 ) | r1 Q1 and r2 Q2 } ((r1 , r2 ), a) = (1 (r1 , a), 2 (r2 , a)) q0 = (q1 , q2 )

= 1 2

Tuesday, September 15, 2009

Q = {(r1 , r2 ) | r1 Q1 and r2 Q2 } ((r1 , r2 ), a) = (1 (r1 , a), 2 (r2 , a)) q0 = (q1 , q2 ) F = {(r1 , r2 ) | r1 F1 or r2 F2 }


Tuesday, September 15, 2009

= 1 2

A1 1 C1

0 0, 1 0, 1

B1

1 A2 0 C2 0, 1 0, 1 B2

Tuesday, September 15, 2009

A1 A2 0 B1 A2 0, 1 C1 B2
Tuesday, September 15, 2009

1 1 0

B1 C2 0, 1 0, 1

C1 C2

Regular languages are

closed under union.


if L1 and L2 are regular languages then L1 L2 is a regular language
Tuesday, September 15, 2009

Reading: Sipser 1.1

Tuesday, September 15, 2009

?
Tuesday, September 15, 2009

WHAT
AUTOMATON RECOGNIZES

L = {w | w = }

?
Tuesday, September 15, 2009

You might also like