SlideShare a Scribd company logo
Dete rministic Finite
Autom ata (DFA)
• DFA can be defined by quintuples
( 𝑄 , Σ , 𝛿 , 𝑞 0 , 𝐹 )
– 𝑄 is finite set of states
– Σ is finite set of alphabets
– 𝛿 is transition function
– 𝑞 0 is initial state
– 𝐹 finite set of final states
1
Example of DFA
𝑄 = 𝐴, 𝐵, 𝐶
Σ = 𝑎, 𝑏
𝛿: 𝑄 Χ Σ → 𝑄
𝑞0 = 𝐴
𝐹 = {𝐵}
2
Transition Function
𝛿: 𝑄 Χ Σ → 𝑄
{A, B, C} X {a, b} {A, B, C}
(A, a)
(A, b)
(B, a)
(B, b)
(C, a)
(C, b)
A
B
C
For every input on a
state there is
exactly one
transition.
3
A
B
C
Question
• Why this FA is called Deterministic Finite
Automata?
– Every state on seeing any input it is always going
to go to only one state.
4
DFA
• Construct a DFA, that accepts set of all strings
over {a, b} of length 2.
• Ans:
– Σ = 𝑎, 𝑏
– 𝐿 = {𝑎𝑎, 𝑎𝑏, 𝑏𝑎, 𝑏𝑏}
B C
A
a a
5
DFA
• Is this a complete DFA?
• No
• Now is this a complete DFA?
• No
• After reaching sate ‘D’ we can’t go back to the final state, that is
why this state is called dead state/trap state.
B C
A
a a
B C
A
B C
A
a, b a, b
a, b a, b
D
a, b
a, b
6
Acceptance
• Acceptance of a string by a FA:
– Scan the entire string and if we reach a final state
from initial state.
• Acceptance of a language by a FA:
– If all the strings in the language are accepted by
the FA and all the strings those are not in the
language must reject by the FA.
7
DFA
• Construct a DFA that accept all strings over the
alphabets {a, b} where the string length is at least 2.
– 𝝎 ∈ 𝒂, 𝒃 and 𝝎 ≥ 𝟐
– 𝜮 = 𝒂, 𝒃
– 𝑳 = {𝒂𝒂, 𝒂𝒃, 𝒃𝒂, 𝒃𝒃, 𝒂𝒂𝒂, … … 𝒃𝒃𝒃, … … … }
– Up to this is a DFA of string length 2. This is not the
required DFA.
– Now this is required DFA.
A B
a,b
C
a,b
a, b
8
DFA
• Construct a DFA that accept all strings over the
alphabets {a, b} where the string length is at most
two.
– 𝝎 ∈ 𝒂, 𝒃 and 𝝎 ≤ 𝟐
– 𝜮 = 𝒂, 𝒃
– 𝑳 = {𝝐, 𝒂, 𝒃, 𝒂𝒂, 𝒂𝒃, 𝒃𝒂, 𝒃𝒃}
– To accept null string (𝝐) the only way to make initial
state to both initial state and final state.
A B
a,b
C
a,b
D
a, b
a, b
9
Minimum numbe r of state s
𝝎 = 𝟐 𝝎 ≥ 𝟐 𝝎 ≤ 𝟐
𝝎 = 𝒏
n + 2
𝝎 ≥ 𝒏
n + 1
𝝎 ≤ 𝒏
n + 2
10
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where the string length is
divisible by two.
• 𝑳 = {𝜖, 𝑎𝑎, 𝑎𝑏, 𝑏𝑎, 𝑏𝑏, 𝑎𝑎𝑎𝑎 … 𝑏𝑏𝑏𝑏 … … … }
• This is not a finite automata
A B
a, b
C
a, b
D
a, b
E
a, b
Length 0 Length 1 Length 2 Length 3 Length 4
11
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where the string length is
divisible by two.
• This is not minimal
A B
a, b
C
a, b
Length 0 Length 1 Length 2
A B
a, b
Length
Even
Length
Odd
a, b
a, b
12
DFA
• Construct a DFA that accept all strings over the
alphabets {a, b} where the string length is not
divisible by two.
• We will get 0 or 1 after diving the length of a string
by two. That is why we need two state.
• If string length is 3 then we will get 0 or 1 or 2 as
remainder after dividing any length by 3. So we will
be requiring three state in that case.
A B
a, b
Length
Even
Length
Odd
a, b
13
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where the string length is
divisible by three.
– 𝜔 𝑚𝑜𝑑 3 = 0
– 𝐿 = {𝜖, 𝑎𝑎𝑎, … … … , 𝑏𝑏𝑏, 𝑎𝑎𝑎𝑎𝑎𝑎, … … … , 𝑏𝑏𝑏𝑏𝑏𝑏, … … … … … … }
A B
a, b
C
a, b
Length
0,3,6,…
Length
1,4,7,…
Length
2,5,8,…
a, b
14
DFA
• Construct a DFA where 𝜔 ≅ 1 𝑚𝑜𝑑 3
• 𝜔 ≅ 1 𝑚𝑜𝑑 3 means 𝜔 𝑚𝑜𝑑 3 = 1
• For 𝜔 𝑚𝑜𝑑 𝑛 = 0 𝑜𝑟 𝜔 ≅ 𝑚 𝑚𝑜𝑑 n (m is any number)
in general for minimal DFA we need 𝑛 number of states.
A
a, b
C
a, b
Length
0,3,6,…
Length
1,4,7,…
Length
2,5,8,…
a, b
B
15
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ in
the string is two.
– 𝑛𝑎 𝜔 = 2
– 𝐿 = 𝑎𝑎, 𝑏𝑎𝑎, 𝑎𝑏𝑎, 𝑎𝑎𝑏, 𝑏𝑏𝑎𝑎, … … …
B
a
C
a
0 ‘a’s 1 ‘a’s 2 ‘a’s
A D
b b b
a
3 ‘a’s
a,b
16
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ in
the string at least two.
– 𝑛𝑎 𝜔 ≥ 2
B
a
C
a
0 ‘a’s 1 ‘a’s 2 ‘a’s
A
b b a, b
17
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ in
the string at most two.
– 𝑛𝑎 𝜔 ≤ 2
b
B
a
C
a
0 ‘a’s 1 ‘a’s 2 ‘a’s
A
b b
D
3 ‘a’s
a,b
a
18
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ in
the string is even.
– 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 0
– 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 2
A B
a
Length
Even
Length
Odd
a
b
b
19
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ in
the string is odd.
– 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 1
– 𝑛𝑎 𝜔 ≅ 1 𝑚𝑜𝑑 2
b
A B
a
Length
Even
Length
Odd
a
b
20
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ in
the string is divisible by 3.
– 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 0
– 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 3
A B
a
a
b
b
C
a
b
21
DFA
• 𝑖𝑓𝑛𝑎 𝜔 ≅ 𝑘 𝑚𝑜𝑑 n , how to draw DFA??
– 𝑛 number of states will be there
• If k=0 𝑞0 will be final state
• If k=1 𝑞1 will be final state
• If k=2 𝑞2 will be final state
• If k=3 𝑞3 will be final state
• So on
22
Assignment
1. Construct a DFA that accept all strings over the
alphabets {a, b} where number of ‘b’ in the string is
divisible by 5.
2. Construct a DFA that accept all strings over the
alphabets {a, b} such that 𝑛𝑎 𝜔 ≅ 2 𝑚𝑜𝑑 5
3. Construct a DFA that accept all strings over the
alphabets {a, b} such that 𝑛𝑏 𝜔 ≅ 1 𝑚𝑜𝑑 3
23
DFA
• Construct a DFA that accept all strings over
the alphabets {a, b} where number of ‘a’ and
number of ‘b’ in the string is even.
– 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 0 & 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 = 0
– 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 2 & 𝑛𝑏 𝜔 ≅ 0 𝑚𝑜𝑑 2
𝑛𝑎 𝜔 𝑛𝑏 𝜔
E E
O E
E O
O O
Four possible
states
representing this
situation
24
DFA
ee eo
oe oo
1. String 𝜖 state ee
2. String ‘a’ state oe
3. String ‘b’ state eo
4. String ‘aa’ state ee
5. String ‘ab’ state oo
6. String ‘ba’ state oo
7. String ‘bb’ state ee
8. String ‘aba’ or ‘baa’ state eo
9. String ‘bab’ or ‘abb’ state oe
a
b
a
b
a
b
a
b
25
Cross Product Method
• 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 0 & 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 = 0
𝐴, 𝐵 × 𝐶, 𝐷 = 𝐴𝐶, 𝐴𝐷, 𝐵𝐶, 𝐵𝐷
A B
a
a
b
b
C D
b
b
a
a
b
a
b
a
b
a
b
a
A B
C C
a
a
b
b
A A
C D
AC BC
AD BD
ee oe
oo
eo
Observation: ‘a’s are counting
in horizontal way and ‘b’s are
counting in vertical way. 26
Cross Product Method
• Construct a DFA that accept all strings over the
alphabets {a, b} where number of ‘a’ is divisible by 3
and number of ‘b’ in the string is divisible by 2.
b
a
a
b
00 10
01 11
20
b
21
a
a
a
a
b
b
b
27
Cross Product Method
• Construct a DFA that accept all strings over the alphabets {a,
b} where number of ‘a’ and number of ‘b’ in the string is
divisible by 3.
– 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 0 & 𝑛𝑏 𝜔 𝑚𝑜𝑑 3 = 0
– 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 3 & 𝑛𝑏 𝜔 ≅ 0 𝑚𝑜𝑑 3
b
a
a
b
A B
D E
C
b
F
a
a
a
a
b
a
b
G H
b
I
a
a
b
b
b
28
DFA
• Construct a DFA that accept all strings over the alphabets {a,
b} such that 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 ≥ 𝑛𝑏 𝜔 𝑚𝑜𝑑 2
b
a
a
b
00 10
01 11
20
b
21
a
a
a
a
b
b
b
No. of ‘a’s mod 3 >
no. of ‘b’s mod 2
this will be a final
state
No. of ‘a’s mod 3 >
no. of ‘b’s mod 2
this will be a final
state
No. of ‘a’s mod 3 =
no. of ‘b’s mod 2
this will be a final
state
No. of ‘a’s mod 3 >
no. of ‘b’s mod 2
this will be a final
state
No. of ‘a’s mod 3 =
no. of ‘b’s mod 2
So this will be a
final state
No. of ‘a’s mod 3 <
no. of ‘b’s mod 2
this will not be a
final state
29
DFA
• Construct a minimal DFA which accepts all
strings over {0,1}, which when interpreted as
binary number is divisible by 2.
– Two remainders are possible, so two states
𝒒𝟎 𝒒𝟏
1
0
1
0
30
DFA
• Construct a minimal DFA which accepts all
strings over {0,1}, which when interpreted as
binary number is divisible by 3.
– Three remainders are possible, so three states
𝒒𝟎 𝒒𝟏
1
1
0
0
𝒒𝟐
0
1
If the question is divisible by ‘n’ then number of state is n.
31
Transition Table
0 1
𝑞0 𝑞0 𝑞1
𝑞1 𝑞2 𝑞0
𝑞2 𝑞1 𝑞2
q0 q1
q2 q0
q1 q2
32
Transition Table
• Construct a minimal DFA which accepts all
strings over {0,1}, which when interpreted as
binary number is divisible by 4
0 1
𝑞0 𝑞0 𝑞1
𝑞1 𝑞2 𝑞3
𝑞2 𝑞0 𝑞1
𝑞3 𝑞2 𝑞3
33
DFA
• Construct a minimal DFA which accepts all
strings over {0,1}, which when interpreted as
binary number is ≅ 1 𝑚𝑜𝑑 3.
𝒒𝟎 𝒒𝟏
1
1
0
0
𝒒𝟏
0
1
34
DFA
• Construct a minimal DFA which accepts all
strings over {0,1}, which when interpreted as
binary number is ≅ 2 𝑚𝑜𝑑 3.
𝒒𝟎 𝒒𝟏
1
1
0
0
𝒒𝟏
0
1
35
Transition Table
• Construct a minimal DFA which accepts all
strings over {0,1,2}, which when interpreted as
ternary number is divisible by 4
0 1 2
𝑞0 𝑞0 𝑞1 𝑞2
𝑞1 𝑞3 𝑞0 𝑞1
𝑞2 𝑞2 𝑞3 𝑞0
𝑞3 𝑞1 𝑞2 𝑞3
36
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} where each string starts
with an ‘a’.
• Construct a minimal DFA which accepts set of
all strings over {a, b} where each string
contains an ‘a’.
• Construct a minimal DFA which accepts set of
all strings over {a, b} where each string ends
with an ‘a’.
37
Assignment
1. Construct a DFA that accept all strings over the alphabets {a, b} where number of
‘a’ and number of ‘b’ is odd in the string.
2. Construct a DFA that accept all strings over the alphabets {a, b} where number of
‘a’ is even and number of ‘b’ is odd in the string .
3. Construct a DFA that accept all strings over the alphabets {a, b} where number of
‘a’ is odd and number of ‘b’ is even in the string .
4. Construct a DFA that accept all strings over the alphabets {a, b} where number of
‘a’ is multiple of three and number of ‘b’ is multiple of two in the string.
5. Construct a DFA that accept all strings over the alphabets {a, b} such that
𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 𝑛𝑏 𝜔 𝑚𝑜𝑑 2
6. Construct a DFA that accept all strings over the alphabets {a, b} such that
𝑛𝑎 𝜔 𝑚𝑜𝑑 3 ≤ 𝑛𝑏 𝜔 𝑚𝑜𝑑 2
7. Construct a DFA that accept all strings over the alphabets {a, b} such that
𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 1 and 𝑛𝑏 𝜔 𝑚𝑜𝑑 3 = 2
8. Construct a DFA that accept all strings over the alphabets {a, b} such that
𝑛𝑎 𝜔 𝑚𝑜𝑑 3 > 𝑛𝑏 𝜔 𝑚𝑜𝑑 3
9. Construct a minimal DFA which accepts all strings over Octal number system,
which when interpreted as binary number ≅ 1 𝑚𝑜𝑑 5
38
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} where each string start
with “ab”
– L= {ab, aba, abb, ………}
B C
A
a b
D
a, b
a
a, b
39
b
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} where each string
contains “ab” as a sub string.
– L= {ab, aab, aba, bab, abb ………}
B C
A
a b
b a a,b
40
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} where each string end
with “ab”
– L= {ab, aab, bab, abab ………}
B C
A
a b
b a
a
b
41
DFA
• Construct a minimal DFA which accepts set of all
strings over {a, b} where each string starts with ‘a’
and ends with ‘b’ or vice versa.
– L ={ab, ba, aab, abb, baa, bba. ……}
B C
A
a b
b
a b
a
D
a
E
b
b
42
a
DFA
• Construct a minimal DFA which accepts set of all
strings over {a, b} where each string starts and ends
with same symbol.
– L={𝜖, a, b, aa, bb, aba, bab,…………}
C
B
A
a b
b
a
b
a
E
a
D b
b
a
This DFA is complement of
previous DFA and language also.
We will get complement of a
language by removing one
language from 𝚺∗. 𝑳𝟐 = 𝚺∗ − 𝑳𝟏
L2 is complement of L1
43
Complement of DFA
A B
a
Length
Even
Length
Odd
a
b
b
A B
a
Length
Even
Length
Odd
a
b
L1 = Even number of ‘a’ L2 = Odd number of ‘a’
L3 = Starts with ‘a’ L4 = Not starts with ‘a’
A B
C
a
b
a,b
a,b
A B
C
a
b
a,b
a,b
44
Complement of DFA
• DFA can be defined by quintuples
– ( 𝑄 , Σ , 𝛿 , 𝑞 0 , 𝐹 )
• Complement of DFA can be defined by
quintuples
– ( 𝑄 , Σ , 𝛿 , 𝑞 0 , 𝑄 − 𝐹 )
45
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} which accepts strings in
which every 'a' is followed by 'b'.
– L={𝜖, b, ab, bb, aba, bab, …………}
46
C
B
A a b
a
b
a
b
D
a,b
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} which accepts strings in
which every 'a' never followed by 'b'.
– This is not complement of previous
– L={𝜖, a, aa,…..,b, bb,……, ba, bba…………}
47
C
B
A
a b
a
a,b
b
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} which accepts strings in
which every 'a' is followed by ‘bb'.
48
D
B
A a b
a
b
a
b
E
a,b
C
b
a
DFA
• Construct a minimal DFA which accepts set of
all strings over {a, b} which accepts strings in
which every 'a' never followed by ‘bb'.
49
D
B
A a b
a, b
a
b
C
b
a
DFA
• 𝐿 = 𝑎𝑛
𝑏𝑚
|𝑛, 𝑚 ≥ 1
– 𝐿 = {𝑎𝑏, 𝑎𝑎𝑏𝑏, 𝑎𝑎𝑎𝑏, 𝑎𝑏𝑏𝑏, … … … }
50
C
B
A a
b
b
a
D
a, b
b
a
DFA
• 𝐿 = 𝑎𝑛
𝑏𝑚
|𝑛, 𝑚 ≥ 0
– 𝐿 = {𝜖, 𝑎, 𝑎𝑎, … , 𝑎𝑎𝑏, 𝑎𝑏𝑏, … 𝑏, 𝑏𝑏, 𝑏𝑏𝑏 … … … }
51
C
B
A
b a
b a,b
a
DFA
• 𝐿 = 𝑎𝑛
𝑏𝑚
𝑐𝑙
|𝑛, 𝑚, 𝑙 ≥ 1
– 𝐿 = {𝑎𝑏𝑐, 𝑎𝑎𝑏𝑐, 𝑎𝑏𝑏𝑐, 𝑎𝑏𝑐𝑐, … … … }
52
D
B
A a
b, c
c
c
D
a, b, c
b
a
C
c
a
b
a, b
DFA
• 𝐿 = 𝑎𝑛
𝑏𝑚
𝑐𝑙
|𝑛, 𝑚, 𝑙 ≥ 0
– 𝐿 = {𝜖, 𝑎, 𝑏, 𝑐, 𝑎𝑏, 𝑎𝑐, 𝑏𝑐, 𝑎𝑏𝑐, 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, … }
53
B
A b c
c
b
a
C
c
a
D
a, b, c
a, b
DFA
• 𝐿 = {𝑎3
𝑏𝑤𝑎3
|𝑤 ∈ {𝑎, 𝑏}∗
}
– 𝐿 = {𝑎3𝑏𝜖𝑎3, 𝑎3𝑏𝑎𝑎3, 𝑎3𝑏𝑏𝑎3, 𝑎3𝑏𝑎𝑎𝑎3, … … }
54
H
B
A a a
C D E F G
a b a a a
I
b
a, b
b b a
b
b
b
b
a
Operations of DFA
Different operations that we can apply on DFAs
are -
1. Union
2. Concatenation
3. Cross Product
4. Complement
5. Reversal
55
Union
• Union of two Regular language is also Regular
– L1 = starts with ‘a’ and ends with ‘b’
– L2 = starts with ‘b’ and ends with ‘a’
– 𝐿 = 𝐿1 ∪ 𝐿2 = starts with different symbol
• Let,
𝑴𝟏 = 𝑄1, Σ1, 𝛿1, 𝑞0
1, 𝐹1 DFA for L1 , 𝑴𝟐 = 𝑄2, Σ2, 𝛿2, 𝑞0
2, 𝐹2 DFA for L2
We want to construct M for 𝑳 = 𝐿1 ∪ 𝐿2
𝑴 = 𝑄, Σ, 𝛿, 𝑞0, 𝐹 DFA for L
Where,
𝑸 = 𝑄1 × 𝑄2
𝜮 = Σ1 ∪ Σ2
𝜹 𝑟1, 𝑟2 , 𝑎 = 𝛿1 𝑟1, 𝑎 , 𝛿2 𝑟2, 𝑎
𝒒𝟎= 𝑞0
1, 𝑞0
2
𝑭 = 𝑟1, 𝑟2 | 𝑟1 ∈ 𝐹1 𝑜𝑟 𝑟2 ∈ 𝐹2
56
𝑟1 ∈ 𝑄1 𝑎𝑛𝑑 𝑟2 ∈ 𝑄2
Union
57
B
A a b
b
a
C
b
D
a, b
a
B
A b a
a
b
C
a
D
a, b
b
b
B
A a b
b
a
C
a
B
b
a
a
b
C
Concatenation
• Concatenation of two Regular language is also Regular
– L1 = starts with ‘a’
– L2 = ends with ‘b’
– 𝐿 = 𝐿1 ∘ 𝐿2 = starts with ‘a’ and ends with ‘b’
𝐿1 = 𝑎, 𝑎𝑎, 𝑎𝑏, 𝑎𝑎𝑏, 𝑎𝑎𝑎, 𝑎𝑏𝑏, … …
𝐿2 = {𝑏, 𝑎𝑏, 𝑏𝑏, 𝑏𝑏𝑏, 𝑎𝑎𝑏, 𝑎𝑏𝑏, … … }
𝐿 = {𝑎𝑏, 𝑎𝑎𝑏, 𝑎𝑏𝑏, 𝑎𝑏𝑏𝑏, … … … }
• Let,
𝑴𝟏 = 𝑄1, Σ1, 𝛿1, 𝑞0
1
, 𝐹1 DFA for L1 , 𝑴𝟐 = 𝑄2, Σ2, 𝛿2, 𝑞0
2
, 𝐹2 DFA for L2
We want to construct M for 𝑳 = 𝐿1 ∘ 𝐿2
𝑴 = 𝑄, Σ, 𝛿, 𝑞0, 𝐹 DFA for L
58
Concatenation
59
A a
a, b
B
b
C
a, b
A b
b
B
a
a
B
A a b
b
a
C
b
D
a, b
a
Reversal
• L1= starts with ‘a’
– 𝐿1 = {a, aa, ab, aaa, aab, aba,……}
– 𝐿1𝑅 = {a, aa, ba, aaa, baa, aba,……}
• Steps:
– States are same as original
– Convert initial state to final state
– Convert final state to initial state
60
A a
a, b
B
b
C
a, b
A
a
a, b
B
b
C
a, b
This is not DFA it is NFA
If we reverse a DFA of a
language we will get a
reverse language, but we
may or may not get
reverse DFA. Reverse FA is
either DFA or NFA.

More Related Content

Similar to 15159222.ppt

Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
Abdul Aziz
 
Lecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.pptLecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.ppt
Venneladonthireddy1
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
Ratnakar Mikkili
 
RegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptxRegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptx
RaviAr5
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
Akila Krishnamoorthy
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
Iffat Anjum
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
ziadk6872
 
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
Ashis Kumar Chanda
 
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
Ashis Chanda
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
Lesson 04
Lesson 04Lesson 04
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
Abdullah Jan
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
Lesson 02Lesson 02
Lesson 02
maamir farooq
 
10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx
MuhammadFaizanHameed1
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
hamzamughal39
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.ppt
AkhlasHashim
 
Chapter 2 limits of DFA NDFA.ppt
Chapter 2  limits of DFA  NDFA.pptChapter 2  limits of DFA  NDFA.ppt
Chapter 2 limits of DFA NDFA.ppt
ArwaKhallouf
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
Rabia Khalid
 

Similar to 15159222.ppt (20)

Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
 
Lecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.pptLecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.ppt
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
To lec 03
To lec 03To lec 03
To lec 03
 
RegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptxRegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptx
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
 
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
 
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Lesson 04
Lesson 04Lesson 04
Lesson 04
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.ppt
 
Chapter 2 limits of DFA NDFA.ppt
Chapter 2  limits of DFA  NDFA.pptChapter 2  limits of DFA  NDFA.ppt
Chapter 2 limits of DFA NDFA.ppt
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 

More from ssuser47f7f2

rs1.ppt
rs1.pptrs1.ppt
rs1.ppt
ssuser47f7f2
 
Lecture7x.ppt
Lecture7x.pptLecture7x.ppt
Lecture7x.ppt
ssuser47f7f2
 
NORMAL-FORMS.ppt
NORMAL-FORMS.pptNORMAL-FORMS.ppt
NORMAL-FORMS.ppt
ssuser47f7f2
 
functions (1).pptx
functions (1).pptxfunctions (1).pptx
functions (1).pptx
ssuser47f7f2
 
09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf
ssuser47f7f2
 
Module 2_Conditional Statements.pptx
Module 2_Conditional Statements.pptxModule 2_Conditional Statements.pptx
Module 2_Conditional Statements.pptx
ssuser47f7f2
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
ssuser47f7f2
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
ssuser47f7f2
 
Module 1-System Software PROGRAMS.pptx
Module 1-System Software PROGRAMS.pptxModule 1-System Software PROGRAMS.pptx
Module 1-System Software PROGRAMS.pptx
ssuser47f7f2
 
module1 network security.pdf
module1 network security.pdfmodule1 network security.pdf
module1 network security.pdf
ssuser47f7f2
 

More from ssuser47f7f2 (10)

rs1.ppt
rs1.pptrs1.ppt
rs1.ppt
 
Lecture7x.ppt
Lecture7x.pptLecture7x.ppt
Lecture7x.ppt
 
NORMAL-FORMS.ppt
NORMAL-FORMS.pptNORMAL-FORMS.ppt
NORMAL-FORMS.ppt
 
functions (1).pptx
functions (1).pptxfunctions (1).pptx
functions (1).pptx
 
09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf
 
Module 2_Conditional Statements.pptx
Module 2_Conditional Statements.pptxModule 2_Conditional Statements.pptx
Module 2_Conditional Statements.pptx
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
Module 1-System Software PROGRAMS.pptx
Module 1-System Software PROGRAMS.pptxModule 1-System Software PROGRAMS.pptx
Module 1-System Software PROGRAMS.pptx
 
module1 network security.pdf
module1 network security.pdfmodule1 network security.pdf
module1 network security.pdf
 

Recently uploaded

WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 

Recently uploaded (20)

WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 

15159222.ppt

  • 1. Dete rministic Finite Autom ata (DFA) • DFA can be defined by quintuples ( 𝑄 , Σ , 𝛿 , 𝑞 0 , 𝐹 ) – 𝑄 is finite set of states – Σ is finite set of alphabets – 𝛿 is transition function – 𝑞 0 is initial state – 𝐹 finite set of final states 1
  • 2. Example of DFA 𝑄 = 𝐴, 𝐵, 𝐶 Σ = 𝑎, 𝑏 𝛿: 𝑄 Χ Σ → 𝑄 𝑞0 = 𝐴 𝐹 = {𝐵} 2
  • 3. Transition Function 𝛿: 𝑄 Χ Σ → 𝑄 {A, B, C} X {a, b} {A, B, C} (A, a) (A, b) (B, a) (B, b) (C, a) (C, b) A B C For every input on a state there is exactly one transition. 3 A B C
  • 4. Question • Why this FA is called Deterministic Finite Automata? – Every state on seeing any input it is always going to go to only one state. 4
  • 5. DFA • Construct a DFA, that accepts set of all strings over {a, b} of length 2. • Ans: – Σ = 𝑎, 𝑏 – 𝐿 = {𝑎𝑎, 𝑎𝑏, 𝑏𝑎, 𝑏𝑏} B C A a a 5
  • 6. DFA • Is this a complete DFA? • No • Now is this a complete DFA? • No • After reaching sate ‘D’ we can’t go back to the final state, that is why this state is called dead state/trap state. B C A a a B C A B C A a, b a, b a, b a, b D a, b a, b 6
  • 7. Acceptance • Acceptance of a string by a FA: – Scan the entire string and if we reach a final state from initial state. • Acceptance of a language by a FA: – If all the strings in the language are accepted by the FA and all the strings those are not in the language must reject by the FA. 7
  • 8. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where the string length is at least 2. – 𝝎 ∈ 𝒂, 𝒃 and 𝝎 ≥ 𝟐 – 𝜮 = 𝒂, 𝒃 – 𝑳 = {𝒂𝒂, 𝒂𝒃, 𝒃𝒂, 𝒃𝒃, 𝒂𝒂𝒂, … … 𝒃𝒃𝒃, … … … } – Up to this is a DFA of string length 2. This is not the required DFA. – Now this is required DFA. A B a,b C a,b a, b 8
  • 9. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where the string length is at most two. – 𝝎 ∈ 𝒂, 𝒃 and 𝝎 ≤ 𝟐 – 𝜮 = 𝒂, 𝒃 – 𝑳 = {𝝐, 𝒂, 𝒃, 𝒂𝒂, 𝒂𝒃, 𝒃𝒂, 𝒃𝒃} – To accept null string (𝝐) the only way to make initial state to both initial state and final state. A B a,b C a,b D a, b a, b 9
  • 10. Minimum numbe r of state s 𝝎 = 𝟐 𝝎 ≥ 𝟐 𝝎 ≤ 𝟐 𝝎 = 𝒏 n + 2 𝝎 ≥ 𝒏 n + 1 𝝎 ≤ 𝒏 n + 2 10
  • 11. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where the string length is divisible by two. • 𝑳 = {𝜖, 𝑎𝑎, 𝑎𝑏, 𝑏𝑎, 𝑏𝑏, 𝑎𝑎𝑎𝑎 … 𝑏𝑏𝑏𝑏 … … … } • This is not a finite automata A B a, b C a, b D a, b E a, b Length 0 Length 1 Length 2 Length 3 Length 4 11
  • 12. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where the string length is divisible by two. • This is not minimal A B a, b C a, b Length 0 Length 1 Length 2 A B a, b Length Even Length Odd a, b a, b 12
  • 13. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where the string length is not divisible by two. • We will get 0 or 1 after diving the length of a string by two. That is why we need two state. • If string length is 3 then we will get 0 or 1 or 2 as remainder after dividing any length by 3. So we will be requiring three state in that case. A B a, b Length Even Length Odd a, b 13
  • 14. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where the string length is divisible by three. – 𝜔 𝑚𝑜𝑑 3 = 0 – 𝐿 = {𝜖, 𝑎𝑎𝑎, … … … , 𝑏𝑏𝑏, 𝑎𝑎𝑎𝑎𝑎𝑎, … … … , 𝑏𝑏𝑏𝑏𝑏𝑏, … … … … … … } A B a, b C a, b Length 0,3,6,… Length 1,4,7,… Length 2,5,8,… a, b 14
  • 15. DFA • Construct a DFA where 𝜔 ≅ 1 𝑚𝑜𝑑 3 • 𝜔 ≅ 1 𝑚𝑜𝑑 3 means 𝜔 𝑚𝑜𝑑 3 = 1 • For 𝜔 𝑚𝑜𝑑 𝑛 = 0 𝑜𝑟 𝜔 ≅ 𝑚 𝑚𝑜𝑑 n (m is any number) in general for minimal DFA we need 𝑛 number of states. A a, b C a, b Length 0,3,6,… Length 1,4,7,… Length 2,5,8,… a, b B 15
  • 16. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ in the string is two. – 𝑛𝑎 𝜔 = 2 – 𝐿 = 𝑎𝑎, 𝑏𝑎𝑎, 𝑎𝑏𝑎, 𝑎𝑎𝑏, 𝑏𝑏𝑎𝑎, … … … B a C a 0 ‘a’s 1 ‘a’s 2 ‘a’s A D b b b a 3 ‘a’s a,b 16
  • 17. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ in the string at least two. – 𝑛𝑎 𝜔 ≥ 2 B a C a 0 ‘a’s 1 ‘a’s 2 ‘a’s A b b a, b 17
  • 18. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ in the string at most two. – 𝑛𝑎 𝜔 ≤ 2 b B a C a 0 ‘a’s 1 ‘a’s 2 ‘a’s A b b D 3 ‘a’s a,b a 18
  • 19. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ in the string is even. – 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 0 – 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 2 A B a Length Even Length Odd a b b 19
  • 20. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ in the string is odd. – 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 1 – 𝑛𝑎 𝜔 ≅ 1 𝑚𝑜𝑑 2 b A B a Length Even Length Odd a b 20
  • 21. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ in the string is divisible by 3. – 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 0 – 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 3 A B a a b b C a b 21
  • 22. DFA • 𝑖𝑓𝑛𝑎 𝜔 ≅ 𝑘 𝑚𝑜𝑑 n , how to draw DFA?? – 𝑛 number of states will be there • If k=0 𝑞0 will be final state • If k=1 𝑞1 will be final state • If k=2 𝑞2 will be final state • If k=3 𝑞3 will be final state • So on 22
  • 23. Assignment 1. Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘b’ in the string is divisible by 5. 2. Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑎 𝜔 ≅ 2 𝑚𝑜𝑑 5 3. Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑏 𝜔 ≅ 1 𝑚𝑜𝑑 3 23
  • 24. DFA • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ and number of ‘b’ in the string is even. – 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 0 & 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 = 0 – 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 2 & 𝑛𝑏 𝜔 ≅ 0 𝑚𝑜𝑑 2 𝑛𝑎 𝜔 𝑛𝑏 𝜔 E E O E E O O O Four possible states representing this situation 24
  • 25. DFA ee eo oe oo 1. String 𝜖 state ee 2. String ‘a’ state oe 3. String ‘b’ state eo 4. String ‘aa’ state ee 5. String ‘ab’ state oo 6. String ‘ba’ state oo 7. String ‘bb’ state ee 8. String ‘aba’ or ‘baa’ state eo 9. String ‘bab’ or ‘abb’ state oe a b a b a b a b 25
  • 26. Cross Product Method • 𝑛𝑎 𝜔 𝑚𝑜𝑑 2 = 0 & 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 = 0 𝐴, 𝐵 × 𝐶, 𝐷 = 𝐴𝐶, 𝐴𝐷, 𝐵𝐶, 𝐵𝐷 A B a a b b C D b b a a b a b a b a b a A B C C a a b b A A C D AC BC AD BD ee oe oo eo Observation: ‘a’s are counting in horizontal way and ‘b’s are counting in vertical way. 26
  • 27. Cross Product Method • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ is divisible by 3 and number of ‘b’ in the string is divisible by 2. b a a b 00 10 01 11 20 b 21 a a a a b b b 27
  • 28. Cross Product Method • Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ and number of ‘b’ in the string is divisible by 3. – 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 0 & 𝑛𝑏 𝜔 𝑚𝑜𝑑 3 = 0 – 𝑛𝑎 𝜔 ≅ 0 𝑚𝑜𝑑 3 & 𝑛𝑏 𝜔 ≅ 0 𝑚𝑜𝑑 3 b a a b A B D E C b F a a a a b a b G H b I a a b b b 28
  • 29. DFA • Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 ≥ 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 b a a b 00 10 01 11 20 b 21 a a a a b b b No. of ‘a’s mod 3 > no. of ‘b’s mod 2 this will be a final state No. of ‘a’s mod 3 > no. of ‘b’s mod 2 this will be a final state No. of ‘a’s mod 3 = no. of ‘b’s mod 2 this will be a final state No. of ‘a’s mod 3 > no. of ‘b’s mod 2 this will be a final state No. of ‘a’s mod 3 = no. of ‘b’s mod 2 So this will be a final state No. of ‘a’s mod 3 < no. of ‘b’s mod 2 this will not be a final state 29
  • 30. DFA • Construct a minimal DFA which accepts all strings over {0,1}, which when interpreted as binary number is divisible by 2. – Two remainders are possible, so two states 𝒒𝟎 𝒒𝟏 1 0 1 0 30
  • 31. DFA • Construct a minimal DFA which accepts all strings over {0,1}, which when interpreted as binary number is divisible by 3. – Three remainders are possible, so three states 𝒒𝟎 𝒒𝟏 1 1 0 0 𝒒𝟐 0 1 If the question is divisible by ‘n’ then number of state is n. 31
  • 32. Transition Table 0 1 𝑞0 𝑞0 𝑞1 𝑞1 𝑞2 𝑞0 𝑞2 𝑞1 𝑞2 q0 q1 q2 q0 q1 q2 32
  • 33. Transition Table • Construct a minimal DFA which accepts all strings over {0,1}, which when interpreted as binary number is divisible by 4 0 1 𝑞0 𝑞0 𝑞1 𝑞1 𝑞2 𝑞3 𝑞2 𝑞0 𝑞1 𝑞3 𝑞2 𝑞3 33
  • 34. DFA • Construct a minimal DFA which accepts all strings over {0,1}, which when interpreted as binary number is ≅ 1 𝑚𝑜𝑑 3. 𝒒𝟎 𝒒𝟏 1 1 0 0 𝒒𝟏 0 1 34
  • 35. DFA • Construct a minimal DFA which accepts all strings over {0,1}, which when interpreted as binary number is ≅ 2 𝑚𝑜𝑑 3. 𝒒𝟎 𝒒𝟏 1 1 0 0 𝒒𝟏 0 1 35
  • 36. Transition Table • Construct a minimal DFA which accepts all strings over {0,1,2}, which when interpreted as ternary number is divisible by 4 0 1 2 𝑞0 𝑞0 𝑞1 𝑞2 𝑞1 𝑞3 𝑞0 𝑞1 𝑞2 𝑞2 𝑞3 𝑞0 𝑞3 𝑞1 𝑞2 𝑞3 36
  • 37. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} where each string starts with an ‘a’. • Construct a minimal DFA which accepts set of all strings over {a, b} where each string contains an ‘a’. • Construct a minimal DFA which accepts set of all strings over {a, b} where each string ends with an ‘a’. 37
  • 38. Assignment 1. Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ and number of ‘b’ is odd in the string. 2. Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ is even and number of ‘b’ is odd in the string . 3. Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ is odd and number of ‘b’ is even in the string . 4. Construct a DFA that accept all strings over the alphabets {a, b} where number of ‘a’ is multiple of three and number of ‘b’ is multiple of two in the string. 5. Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 6. Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 ≤ 𝑛𝑏 𝜔 𝑚𝑜𝑑 2 7. Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 = 1 and 𝑛𝑏 𝜔 𝑚𝑜𝑑 3 = 2 8. Construct a DFA that accept all strings over the alphabets {a, b} such that 𝑛𝑎 𝜔 𝑚𝑜𝑑 3 > 𝑛𝑏 𝜔 𝑚𝑜𝑑 3 9. Construct a minimal DFA which accepts all strings over Octal number system, which when interpreted as binary number ≅ 1 𝑚𝑜𝑑 5 38
  • 39. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} where each string start with “ab” – L= {ab, aba, abb, ………} B C A a b D a, b a a, b 39 b
  • 40. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} where each string contains “ab” as a sub string. – L= {ab, aab, aba, bab, abb ………} B C A a b b a a,b 40
  • 41. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} where each string end with “ab” – L= {ab, aab, bab, abab ………} B C A a b b a a b 41
  • 42. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} where each string starts with ‘a’ and ends with ‘b’ or vice versa. – L ={ab, ba, aab, abb, baa, bba. ……} B C A a b b a b a D a E b b 42 a
  • 43. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} where each string starts and ends with same symbol. – L={𝜖, a, b, aa, bb, aba, bab,…………} C B A a b b a b a E a D b b a This DFA is complement of previous DFA and language also. We will get complement of a language by removing one language from 𝚺∗. 𝑳𝟐 = 𝚺∗ − 𝑳𝟏 L2 is complement of L1 43
  • 44. Complement of DFA A B a Length Even Length Odd a b b A B a Length Even Length Odd a b L1 = Even number of ‘a’ L2 = Odd number of ‘a’ L3 = Starts with ‘a’ L4 = Not starts with ‘a’ A B C a b a,b a,b A B C a b a,b a,b 44
  • 45. Complement of DFA • DFA can be defined by quintuples – ( 𝑄 , Σ , 𝛿 , 𝑞 0 , 𝐹 ) • Complement of DFA can be defined by quintuples – ( 𝑄 , Σ , 𝛿 , 𝑞 0 , 𝑄 − 𝐹 ) 45
  • 46. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} which accepts strings in which every 'a' is followed by 'b'. – L={𝜖, b, ab, bb, aba, bab, …………} 46 C B A a b a b a b D a,b
  • 47. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} which accepts strings in which every 'a' never followed by 'b'. – This is not complement of previous – L={𝜖, a, aa,…..,b, bb,……, ba, bba…………} 47 C B A a b a a,b b
  • 48. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} which accepts strings in which every 'a' is followed by ‘bb'. 48 D B A a b a b a b E a,b C b a
  • 49. DFA • Construct a minimal DFA which accepts set of all strings over {a, b} which accepts strings in which every 'a' never followed by ‘bb'. 49 D B A a b a, b a b C b a
  • 50. DFA • 𝐿 = 𝑎𝑛 𝑏𝑚 |𝑛, 𝑚 ≥ 1 – 𝐿 = {𝑎𝑏, 𝑎𝑎𝑏𝑏, 𝑎𝑎𝑎𝑏, 𝑎𝑏𝑏𝑏, … … … } 50 C B A a b b a D a, b b a
  • 51. DFA • 𝐿 = 𝑎𝑛 𝑏𝑚 |𝑛, 𝑚 ≥ 0 – 𝐿 = {𝜖, 𝑎, 𝑎𝑎, … , 𝑎𝑎𝑏, 𝑎𝑏𝑏, … 𝑏, 𝑏𝑏, 𝑏𝑏𝑏 … … … } 51 C B A b a b a,b a
  • 52. DFA • 𝐿 = 𝑎𝑛 𝑏𝑚 𝑐𝑙 |𝑛, 𝑚, 𝑙 ≥ 1 – 𝐿 = {𝑎𝑏𝑐, 𝑎𝑎𝑏𝑐, 𝑎𝑏𝑏𝑐, 𝑎𝑏𝑐𝑐, … … … } 52 D B A a b, c c c D a, b, c b a C c a b a, b
  • 53. DFA • 𝐿 = 𝑎𝑛 𝑏𝑚 𝑐𝑙 |𝑛, 𝑚, 𝑙 ≥ 0 – 𝐿 = {𝜖, 𝑎, 𝑏, 𝑐, 𝑎𝑏, 𝑎𝑐, 𝑏𝑐, 𝑎𝑏𝑐, 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, … } 53 B A b c c b a C c a D a, b, c a, b
  • 54. DFA • 𝐿 = {𝑎3 𝑏𝑤𝑎3 |𝑤 ∈ {𝑎, 𝑏}∗ } – 𝐿 = {𝑎3𝑏𝜖𝑎3, 𝑎3𝑏𝑎𝑎3, 𝑎3𝑏𝑏𝑎3, 𝑎3𝑏𝑎𝑎𝑎3, … … } 54 H B A a a C D E F G a b a a a I b a, b b b a b b b b a
  • 55. Operations of DFA Different operations that we can apply on DFAs are - 1. Union 2. Concatenation 3. Cross Product 4. Complement 5. Reversal 55
  • 56. Union • Union of two Regular language is also Regular – L1 = starts with ‘a’ and ends with ‘b’ – L2 = starts with ‘b’ and ends with ‘a’ – 𝐿 = 𝐿1 ∪ 𝐿2 = starts with different symbol • Let, 𝑴𝟏 = 𝑄1, Σ1, 𝛿1, 𝑞0 1, 𝐹1 DFA for L1 , 𝑴𝟐 = 𝑄2, Σ2, 𝛿2, 𝑞0 2, 𝐹2 DFA for L2 We want to construct M for 𝑳 = 𝐿1 ∪ 𝐿2 𝑴 = 𝑄, Σ, 𝛿, 𝑞0, 𝐹 DFA for L Where, 𝑸 = 𝑄1 × 𝑄2 𝜮 = Σ1 ∪ Σ2 𝜹 𝑟1, 𝑟2 , 𝑎 = 𝛿1 𝑟1, 𝑎 , 𝛿2 𝑟2, 𝑎 𝒒𝟎= 𝑞0 1, 𝑞0 2 𝑭 = 𝑟1, 𝑟2 | 𝑟1 ∈ 𝐹1 𝑜𝑟 𝑟2 ∈ 𝐹2 56 𝑟1 ∈ 𝑄1 𝑎𝑛𝑑 𝑟2 ∈ 𝑄2
  • 57. Union 57 B A a b b a C b D a, b a B A b a a b C a D a, b b b B A a b b a C a B b a a b C
  • 58. Concatenation • Concatenation of two Regular language is also Regular – L1 = starts with ‘a’ – L2 = ends with ‘b’ – 𝐿 = 𝐿1 ∘ 𝐿2 = starts with ‘a’ and ends with ‘b’ 𝐿1 = 𝑎, 𝑎𝑎, 𝑎𝑏, 𝑎𝑎𝑏, 𝑎𝑎𝑎, 𝑎𝑏𝑏, … … 𝐿2 = {𝑏, 𝑎𝑏, 𝑏𝑏, 𝑏𝑏𝑏, 𝑎𝑎𝑏, 𝑎𝑏𝑏, … … } 𝐿 = {𝑎𝑏, 𝑎𝑎𝑏, 𝑎𝑏𝑏, 𝑎𝑏𝑏𝑏, … … … } • Let, 𝑴𝟏 = 𝑄1, Σ1, 𝛿1, 𝑞0 1 , 𝐹1 DFA for L1 , 𝑴𝟐 = 𝑄2, Σ2, 𝛿2, 𝑞0 2 , 𝐹2 DFA for L2 We want to construct M for 𝑳 = 𝐿1 ∘ 𝐿2 𝑴 = 𝑄, Σ, 𝛿, 𝑞0, 𝐹 DFA for L 58
  • 59. Concatenation 59 A a a, b B b C a, b A b b B a a B A a b b a C b D a, b a
  • 60. Reversal • L1= starts with ‘a’ – 𝐿1 = {a, aa, ab, aaa, aab, aba,……} – 𝐿1𝑅 = {a, aa, ba, aaa, baa, aba,……} • Steps: – States are same as original – Convert initial state to final state – Convert final state to initial state 60 A a a, b B b C a, b A a a, b B b C a, b This is not DFA it is NFA If we reverse a DFA of a language we will get a reverse language, but we may or may not get reverse DFA. Reverse FA is either DFA or NFA.

Editor's Notes

  1. ≅ congruent to
  2. E = Even, O = Odd
  3. Lecture 8: {0,1,2} ternary number where base is 3.
  4. This rule is only for DFA’s not for NFA’s
  5. Final state of 1st DFA is initial state of 2nd DFA
  6. If we reverse a DFA of a language we will get a reverse language, but we may or may not get reverse DFA. Reverse FA is either DFA or NFA.