Sunteți pe pagina 1din 12

10/29/2018

Theory of Computation
Dr. Muzammil Khan

Assistant Professor
Department of Computer Science

Office E - 12
1

Chapter 4

Finite Automata

Theory of Computation
2

1
10/29/2018

Finite Automata “FA”


 The word Automata is
 The plural of Greek word “Automaton”
 Means
 Something that work Automatically

 It is called FA because
 Finite, because
 The number of states and the letters both are finite
 Automata, because
 The change of the state is totally govern by the input or
 The determination of what state is next is automatic not
willful

Theory of Computation
3

Finite Automata (Cont...)


 Finite Automata is
 A language recognizer or
 Token recognizer
 Regular Expression is
 Language specifier or
 Language generator

 FA has two types


1. DFA (Deterministic Finite Automata)
 Simply called FA
2. NFA (Non-deterministic Finite Automata)

Theory of Computation
4

2
10/29/2018

Finite Automata “FA or DFA”


 Recursive definition of FA
 A finite automata is the collection of three things
1. Finite set of states
 One initial state, intermediate states and may a final state(s)
2. Finite set of transitions
 Change in states
3. An alphabet
 Possible input letters

 Also refer as Finite Accepter, because


 It accept certain input strings and reject the others

Theory of Computation
5

DFA (Cont...)
 Formal definition of DFA
 FA is a set of five tuple
 That is
 FA = {Q, ∑, σ, S, F}

 Where
 Q is set of states
 ∑ is an alphabet
 σ is a transition
i.e. σ: Q x ZQ is a transition function
 S is start/ initial state, usually q0 i.e. q0∈Q
 F is set of final states F Q

Theory of Computation
6

3
10/29/2018

DFA Example
 Where
 Q = {q0, q1, q2, q3}
 ∑ = {a, b}
 S = {q0}
 F = {q1, q3}
 Transitions (can use Transition table)
 σ (q0, a)q1,
 σ (q0, b)q2,
 σ (q1, a,b)q3,
 σ (q2, a)q2,
 σ (q2, b)q3 and
 σ (q3, a,b)q3

Theory of Computation
7

Pictorial Representation or
Transition Diagram of DFA
 In pictorial representation
 State is represented by small circle
 Start / Initial state as , , , ,

 Intermediate state , ,

 Final state , ,
 Also called halt state, terminal state, accepting state etc…

 Both final and start state ,

 Dead state / garbage collector / trap state


 Any unusual state representation

Theory of Computation
8

4
10/29/2018

Pictorial Representation or
Transition Diagram of DFA (Cont…)
 In pictorial representation
 Transition represented by arrow “ ”
 Arrow head shows direction of transition
 Labeled by input (symbol from the alphabet)

 Transition Types
 Incoming transition
 Transition entering a state
 Outgoing transition
 Transition going away from a state
 Loop transition
 Transition start and end at the same state

Theory of Computation
9

Transition Table
 Transition
 Changing of state by reading / scanning an input

 Transition Table
 Summarize form of transitions
 Provide all the information about FA
 In table format, where
 Each row represent a state of FA
 Each column represent is letter
of input alphabet

Theory of Computation
10

5
10/29/2018

Rules for DFA or FA


 The following should be follow during construction of
DFA
 Cannot take empty / null transition i.e. Λ
 Transition for each input letter i.e. alphabet symbols
 At every state
 Only one transition for a letter over a state
 Only one initial state
 One, many or none final state(s)
 No transition for a string or substring

Theory of Computation
11

Examples: Convert RE to DFA


 RE = (a + b)*
 Accept all words

 RE = a (a + b)*
 Words starting with “a”

 RE = (a + b)+ FA ?

Theory of Computation
12

6
10/29/2018

Examples: Convert RE to DFA (Cont…)


 FA that accept no language
 Many options

 RE = (a + b)
 Simply convert RE to FA first, then
 Complete the FA

Theory of Computation
13

Examples: Convert RE to DFA (Cont…)


 Language of words starting and ending with 0 over ∑ =
{0,1}
 RE = 0 (0 + 1)* 0
 DFA

 RE = a* RE = a+

Theory of Computation
14

7
10/29/2018

Examples: Convert RE to DFA (Cont…)


 RE = a a*b* = a+b* (Which one is correct ?)

 Language starting and ending with


the same letter
 RE = a (a + b)* a + b (a + b)* b
 DFA
 Can we construct DFA with
only final state ?
Theory of Computation
15

Examples: Convert RE to DFA (Cont…)


 DFAs with different number of states for RE = a (a + b)*
 FA with 3 states

 FA with 4 states

 Can be extended further . . .


 DFAs with different number of states for RE = a (a + b)+?
Theory of Computation
16

8
10/29/2018

Examples: Convert RE to DFA (Cont…)


 Language with words having 3rd b
 RE = (a+b)(a+b) b (a+b)* = (a+b)2 b (a+b)*

 Language with even length


 RE = ((a+b)(a+b))*

 Odd length i.e. RE = (a+b) ((a+b)(a+b))* then DFA ?


Theory of Computation
17

Examples: Convert RE to DFA (Cont…)


 Language containing at least one “aa”

 Language whose words start with “aa”

 Language whose words start and end with “aa”

Theory of Computation
18

9
10/29/2018

Examples: Convert RE to DFA (Cont…)


 Even-even language
 RE = ( (aa+bb)+(ab+ba)(aa+bb)*(ab+ba) )*

 Language that accept on λ

Theory of Computation
19

Examples: Convert RE to DFA (Cont…)


 RE = (0+1)* (00+11) (0+1)*

 RE = (a+b)* (aaa+bbb) (a+b)*

Theory of Computation
20

10
10/29/2018

Finite Languages
Examples: Convert RE to DFA
 DFA that accept baa only i.e. L = {baa}

 DFA that accept bba, ab only i.e. L = {bba, ab} ?


 Language with words having length 3
 RE = (a+b)(a+b)(a+b) = (a+b)3

Theory of Computation
21

Examples: Convert RE to DFA (Cont…)


 L = {λ, b, ab, bb}
So RE = {λ + b + ab + bb}

Theory of Computation
22

11
10/29/2018

Examples: Convert RE to DFA (Cont…)


 Language starts and ends with the same letter
 Language having at least one “a” and “b”
 Language contain 3,5,6,9 clumps of “a”
 Language of words containing no substring “bb”
 Language of words that do not have substring “ab”
 Solve as many example you can

 Homework
 Solve the Exercise
 Questions 1.1 to 1.7
 Page # 83,84

Theory of Computation
23

End of Chapter

You may have quiz next week.

Theory of Computation
24

12

S-ar putea să vă placă și