0% found this document useful (0 votes)
75 views72 pages

CS-850: Advanced Theory of Computation: Adnan Rashid

This document summarizes a lecture on deterministic finite automata (DFAs) from an advanced theory of computation course. It introduces DFAs, including their components like states, transitions, alphabets, and accepting/rejecting strings. Examples are provided to demonstrate how a DFA works by scanning an input string and determining whether to accept or reject it based on reaching an accepting state. The formal definition of a DFA is also explained.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views72 pages

CS-850: Advanced Theory of Computation: Adnan Rashid

This document summarizes a lecture on deterministic finite automata (DFAs) from an advanced theory of computation course. It introduces DFAs, including their components like states, transitions, alphabets, and accepting/rejecting strings. Examples are provided to demonstrate how a DFA works by scanning an input string and determining whether to accept or reject it based on reaching an accepting state. The formal definition of a DFA is also explained.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

CS-850: Advanced

Theory of Computation
(Spring 2020)

Lecture 3
Adnan Rashid

Adnan Rashid Advanced Theory of Computation 1


Deterministic Finite
Automaton (DFA)
Input Tape

String

Output

“Accept”
or
“Reject”

Finite Automaton/
Finite State Machine
Adnan Rashid Advanced Theory of Computation 2
Deterministic Finite
Automaton (DFA)
a, b

q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
initial final
state (accepting)
state transition state
Adnan Rashid Advanced Theory of Computation 3
Deterministic Finite
Automaton (DFA)
Alphabet  = {a , b } a, b

q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4

For every state, there is a transition


for every symbol in the alphabet
Adnan Rashid Advanced Theory of Computation 4
DFA: Initial Configuration

Adnan Rashid Advanced Theory of Computation 5


DFA: Scanning the Input

Adnan Rashid Advanced Theory of Computation 6


DFA: Scanning forward…

Adnan Rashid Advanced Theory of Computation 7


DFA: Scanning forward…

Adnan Rashid Advanced Theory of Computation 8


DFA: Input finished

Last state determines the outcome


Adnan Rashid Advanced Theory of Computation 9
DFA: A Rejection Case

Adnan Rashid Advanced Theory of Computation 10


DFA: Scanning forward…

Adnan Rashid Advanced Theory of Computation 11


DFA: Scanning forward…

Adnan Rashid Advanced Theory of Computation 12


DFA: Input finished

Last state determines the outcome


Adnan Rashid Advanced Theory of Computation 13
DFA: Empty Tape

Adnan Rashid Advanced Theory of Computation 14


DFA: Another Rejection
Case

Adnan Rashid Advanced Theory of Computation 15


DFA: Accepted Language
This automaton accepts only one string
Language Accepted: L = abba 

Adnan Rashid Advanced Theory of Computation 16


DFA: String
Acceptance/Rejection
To accept a string:
all the input string is scanned and the
last state is accepting

To reject a string:
all the input string is scanned and the
last state is non-accepting
Adnan Rashid Advanced Theory of Computation 17
Activity
Write the language of the following DFA

L = ab, abba

Accept Accept
state state
Adnan Rashid Advanced Theory of Computation 18
DFA: Empty Tape

Adnan Rashid Advanced Theory of Computation 19


DFA: Empty Tape

Adnan Rashid Advanced Theory of Computation 20


DFA: Example 1

L = , ab, abba 

Accept Accept Accept


state state state
Adnan Rashid Advanced Theory of Computation 21
DFA: Example 2

Adnan Rashid Advanced Theory of Computation 22


Example 2
(Initial Configuration)

Adnan Rashid Advanced Theory of Computation 23


Example 2 (Scanning …)

Adnan Rashid Advanced Theory of Computation 24


Example 2 (Scanning …)

Adnan Rashid Advanced Theory of Computation 25


Example 2
(Input Finished)

Adnan Rashid Advanced Theory of Computation 26


Example 3: A Rejection
Case

Adnan Rashid Advanced Theory of Computation 27


Example 3: Scanning …

Adnan Rashid Advanced Theory of Computation 28


Example 3: Scanning …

Adnan Rashid Advanced Theory of Computation 29


Example 3: Input Finished

Adnan Rashid Advanced Theory of Computation 30


Example 3: Language
Accepted

L = {a b : n  0 }
n

Adnan Rashid Advanced Theory of Computation 31


Example 4

Adnan Rashid Advanced Theory of Computation 32


Formal Definition of DFA
M = (Q, , , q0 , F )
Q : set of states
 : input alphabet  
 : transition function
q0 : initial state

F : set of accepting states


Adnan Rashid Advanced Theory of Computation 33
DFA Example

Adnan Rashid Advanced Theory of Computation 34


Set of States Q

Q = q0 , q1, q2 , q3 , q4 , q5

Adnan Rashid Advanced Theory of Computation 35


Input Alphabet 

 = a, b

Adnan Rashid Advanced Theory of Computation 36


Initial State q0

Adnan Rashid Advanced Theory of Computation 37


Set of Accepting
States F
F Q
F = q4 

Adnan Rashid Advanced Theory of Computation 38


Transition Function 

 :Q → Q

Describes the result of a transition


from state q with symbol x
Adnan Rashid Advanced Theory of Computation 39
Transition Function

 (q0 , a ) = q1

Adnan Rashid Advanced Theory of Computation 40


Transition Function

 (q2 , b ) = q3

Adnan Rashid Advanced Theory of Computation 41


Transition Table for 

Adnan Rashid Advanced Theory of Computation 42


Activity
Write the formal definition of the following DFA

1
a b
1
0 0 0 0
1
c d
1
Adnan Rashid Advanced Theory of Computation 43
Activity
M = (Q, , , q0 , F )
Q = a, b, c, d 
 = 0,1
Initial state = a
F = d 

Adnan Rashid Advanced Theory of Computation 44


Activity
M = (Q, , , q0 , F )
symbols
 1 0
a b c
states

b a d
c d a
d c b
Adnan Rashid Advanced Theory of Computation 45
Extended Transition
Function
 :Q   → Q
* *

 (q ,w ) = q 
*

Describes the resulting state after


scanning string w from state q

Adnan Rashid Advanced Theory of Computation 46


Example

 (q0 , ab ) = q2
*

Adnan Rashid Advanced Theory of Computation 47


Example

 (q1, bba ) = q4
*

Adnan Rashid Advanced Theory of Computation 48


Example: Special Case

Adnan Rashid Advanced Theory of Computation 49


Walk of Transitions
Generally,  (q ,w ) = q 
*
implies that

there is a walk of transitions

w =  1 2  k

states may be repeated

Adnan Rashid Advanced Theory of Computation 50


Language Accepted by
DFA
Language accepted by DFA M:

It is denoted as L (M ) and contains all


the strings accepted by M

We also say that M recognizes L (M )

Adnan Rashid Advanced Theory of Computation 51


Language Accepted by
DFA
For a DFA M = (Q, , , q0 , F )

Language accepted by DFA M:



L(M ) = w   :  (q0 ,w )  F
* *

Adnan Rashid Advanced Theory of Computation 52


Language Rejected by DFA

Language rejected by DFA M:


L(M ) = w   :  (q0 ,w )  F
* *

Adnan Rashid Advanced Theory of Computation 53


Example 1

 = {a , b }

L(M ) = { }
Empty language

Adnan Rashid Advanced Theory of Computation 54


Example 2

 = {a , b }

L( M ) =  *
All strings

Adnan Rashid Advanced Theory of Computation 55


Activity
Write down the Language accepted by the
following automaton

 = {a , b }

L(M ) = { }
Language of the empty string
Adnan Rashid Advanced Theory of Computation 56
Example 3

 = {a , b }

L(M ) = { all strings with prefix ab}


Adnan Rashid Advanced Theory of Computation 57
Activity
Write down the Language accepted by the
following automaton

L (M ) = {all binary strings containing substring 001 }


Adnan Rashid Advanced Theory of Computation 58
Example 4

L (M ) = {all binary strings without substring 001 }

Adnan Rashid Advanced Theory of Computation 59


Example 5


L(M ) = awa : w  a , b 
*

Adnan Rashid Advanced Theory of Computation 60
Regular Languages

Definition:

A language L is regular if there is a DFA M


that accepts it ( L(M ) = L)

Adnan Rashid Advanced Theory of Computation 61


Regular Languages:
Examples
▪ abba
▪  , ab, abba
▪ {a b : n  0}
n

▪ awa : w  a ,b *

▪ {all strings in {a,b}* with prefix ab}


▪ {all binary strings without substring 001 }

Adnan Rashid Advanced Theory of Computation 62


Regular Languages:
Examples
▪ {x : x  {1} and x is even}
*

▪ { }
▪ { }
▪ {a , b } *

There exist DFAs that accept these languages


(As seen in the previous slides)

Adnan Rashid Advanced Theory of Computation 63


Non-regular Languages

There exist languages which are not Regular.

L= {a b : n  0}
n n

ADDITION = {x + y = z : x = 1 , y = 1 , z = 1 , n + m = k}
n m k

There are no DFAs that accept these languages

Adnan Rashid Advanced Theory of Computation 64


Designing a DFA for a
Regular Language
L (M ) = {all binary strings containing substring 001}
▪ Strings in the language
• 0010
• 001
• 1001
• 1111111001111
▪ Strings not in the language
• 11
• 0000
Adnan Rashid Advanced Theory of Computation 65
DFA for a Regular
Language
▪ Four possibilities for the pattern of string
• Have not seen any symbol of the pattern
• Have just seen a 0
• Have just seen a 00
• Have seen the entire pattern 001

▪ Assign states q, q0 , q00, q001 to each of these


possibilities

Adnan Rashid Advanced Theory of Computation 66


DFA for a Regular
Language
Substring 001

Adnan Rashid Advanced Theory of Computation 67


DFA for a Regular
Language
▪ q reading a 1 then stay in q Substring 001
▪ q reading a 0 then move to q0

Adnan Rashid Advanced Theory of Computation 68


DFA for a Regular
Language
▪ q0 reading a 1 then return to q Substring 001
▪ q0 reading a 0 then move to q00

Adnan Rashid Advanced Theory of Computation 69


DFA for a Regular
Language
▪ q00 reading a 1 then move to q001 Substring 001
▪ q00 reading a 0 then stay at q00

Adnan Rashid Advanced Theory of Computation 70


DFA for a Regular
Language
▪ q001 reading a 1 then stay at q001 Substring 001
▪ q001 reading a 0 then stay at q001

Adnan Rashid Advanced Theory of Computation 71


Thank you!

Adnan Rashid Advanced Theory of Computation 72

You might also like