0% found this document useful (0 votes)
69 views42 pages

Theory of Computation Lect3-4-5

1. The document describes finite automata (FAs) and their use in recognizing formal languages. 2. An FA is defined as a 5-tuple (Q, Σ, δ, q0, F) where Q is a set of states, Σ is an input alphabet, δ is the transition function, q0 is the initial state, and F is the set of accepting states. 3. The language accepted by an FA (L(M)) consists of all strings that cause the FA to enter an accepting state when read as input.

Uploaded by

Anik
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views42 pages

Theory of Computation Lect3-4-5

1. The document describes finite automata (FAs) and their use in recognizing formal languages. 2. An FA is defined as a 5-tuple (Q, Σ, δ, q0, F) where Q is a set of states, Σ is an input alphabet, δ is the transition function, q0 is the initial state, and F is the set of accepting states. 3. The language accepted by an FA (L(M)) consists of all strings that cause the FA to enter an accepting state when read as input.

Uploaded by

Anik
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 42

Formal Languages

Finite Automata
Finite Automaton

Input
String
Output
“Accept”
Finite
or
Automaton
“Reject”

2
Transition Graph
a, b

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

initial accepting
state state
transition
state
3
Initial Configuration
Input String
a b b a

a, b

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

4
Reading the Input

a b b a

a, b

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

5
a b b a

a, b

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

6
a b b a

a, b

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

7
a b b a

a, b

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

8
Input finished

a b b a

a, b

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

accept
9
Rejection

a b a

a, b

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

10
a b a

a, b

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

11
a b a

a, b

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

12
a b a

a, b

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

13
Input finished

a b a

a, b

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

14
Acceptance or Rejection?

a, b

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

15
Initial State

a, b

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

16
Rejection

a, b

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

reject
17
Languages Accepted by FAs
FA M

Definition:
The language L M  contains
all input strings accepted by M

L M  = { strings that bring M


to an accepting state}

18
Example

L M   {a b : n  0}
n

a a,b

q0 b q1 a, b q2

accept trap state

19
Deterministic finite automata
A deterministic finite automaton (DFA) is a 5-
tuple (Q, , , q0, F) where
Q is a finite set of states
 is an alphabet
: Q ×  → Q is a transition function
q0  Q is the initial state
F  Q is a set of accepting states (or final states).

In diagrams, the accepting states will be


denoted by double loops
Input Alphabet 

   a, b

b a a, b
a
q0 q1 b q2

21
Set of States Q

Q   q0 , q1 , q2 

b a a, b
a
q0 q1 b q2

22
Initial State q0

b a a, b
a
q0 q1 b q2

23
Set of Accepting States F

F  q2 
b a a, b
a
q0 q1 b q2

24
Transition Function 

 :Q  Q

b a a, b
a
q0 q1 b q2

25
  q0 , a   q1

b a a, b
a
q0 q1 b q2

26
  q0 , b   q0

b a a, b
a
q0 q1 b q2

27
  q1 , b   q2

b a a, b
a
q0 q1 b q2

28
Transition Function 

 a b :Start State
q0 q1 q0 :Final State
q1 q1 q2
q2 q2 q2

b a a, b
a
q0 q1 b q2

29
Extended Transition Function  *

 * : Q  *  Q

b a a, b
a
q0 q1 b q2

30
 *  q0 , ab   q2

b a a, b
a
q0 q1 b q2

31
Example: There is a walk from q0 to q4
with label abba

 *  q0 , abba   q4

a, b

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

32
Recursive Definition
 *  q,    q
 *  q, w    ( * (q, w), )

q w q1  q

 *  q , w    q
 *  q, w    (q1, )
 (q1, )  q
 *  q, w    ( * (q, w), )
 *  q, w  q1

33
 *  q0 , ab  
   * (q0 , a ), b  
     *  q0 ,  , a , b  
    q0 , a , b  
  q1 , b  
q2 a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
34
Language Accepted by FAs
For a FA M   Q, ,  , q0 , F 

Language accepted by M :
L M    w  * :  *  q0 , w  F 

q0 w q q  F

35
Observation
Language rejected by M :

L M    w  * :  *  q0 , w  F 

q0 w q q  F

36
L(M) ?
ab
a, b

q0 a q1 b q2

b a accept

q3 a, b

37
Example
L M  = { all strings with prefix ab }
a, b

q0 a q1 b q2

b a accept

q3 a, b

38
L(M)?

1 0 0,1
1

 0 1
0 00 001

0
39
Example
L  M  = { all strings without
substring 001 }

1 0 0,1
1

 0 1
0 00 001

0
40
L(M) ?

a
b
b
q0 a q2 q3

b a
q4

a, b
41
Example

L( M )   awa : w   a, b *
a
b
b
q0 a q2 q3

b a
q4

a, b
42

You might also like