SlideShare a Scribd company logo
FORMAL LANGUAGES & AUTOMATA THEORY
MODULE 2
PRIYA MARIAM RAJU
ASSISTANT PROFESSOR
DEPARTMENT OF INFORMATION TECHNOLOGY
RAJAGIRI SCHOOL OF ENGINEERING & TECHNOLOGY
Converting Regular Expressions to Automata
The basis of the construction of an automaton from a regular expression
(a) R + S
(b) RS
(c) R*
1. Convert the Regular Expression (0+1)*1(0+1)
to an epsilon NFA
2. Convert the Regular expression 01 + 101 to an epsilon NFA
3. Convert the Regular expression (a+b)*a to an epsilon NFA
3. Convert the Regular expression a + ba* to an epsilon NFA
Regular Expressions to NFA
• a + b
• ab
• a*
A B
a, b
A B C
a b
A
a
Convert the regular expression ba*b to NFA
• L = {bb, bab, baab,…}
Convert the regular expression (a+b)c to NFA
Convert the regular expression a(bc)* to NFA
L = {a, abc, abcbc,….}
Convert the regular expression 10 = (0+11)0*1
Conversion of Automata to Regular Expressions – State Elimination Method
• Rule 1: If there are incoming transitions to the initial state, to get rid of incoming edges
make a new start state with no incoming edges and an outgoing edge to the old start
state with Ɛ-transition. The initial state before is now normal state with added incoming
Ɛ-transition.
Conversion of DFA to Regular Expressions – State Elimination Method
• Rule-2 :
If there are outgoing transitions from final state, to get rid of outgoing edges make a
new final state with no outgoing edges and an incoming edge from old final state of Ɛ-
transition. Old final state is transformed into normal state with the added transition of Ɛ.
Conversion of DFA to Regular Expressions – State Elimination Method
• Rule-3 :
If the Automata have multiple final states it is recommended to strip their status of
being final states and add outgoing Ɛ-transition to new and only final state with no
outgoing transitions.
Rule 4: Eliminating intermediate states
1 2 3
a b
1 3
ab
b
1 2
a
1 3
a+b
1
a
2
b 1 2
a*b
1. Convert the given DFA to regular expression by state
elimination method
2. Convert the given DFA to regular expression by state elimination method (DFA with multiple final
states)
3. Convert the given DFA to regular
expression by state elimination method
4. Convert the given DFA to regular
expression by state elimination method
Proving Languages Not to Be Regular
• We have established that the class of languages known as the regular languages has at least four
different descriptions.
• They are the languages accepted by DFAs, by NFAs and by ϵ-NFAs and they are also the languages
defined by regular expressions.
• Not every language is a regular language.
• In this section we shall introduce a powerful technique known as the pumping lemma for showing
certain languages not to be regular.
The Pumping Lemma for Regular Languages
• Pumping Lemma is used to prove that a language is NOT REGULAR.
• It cannot be used to prove that a language is REGULAR.
• THEOREM: If L is a regular language, then L has a pumping length ‘P’ such that any string S where
|S|>=P may be divided into 3 parts S = xyz such that the following conditions must be true:
1) 𝑥𝑦𝑖𝑧 ∈ 𝐿 for every 𝑖 ≥ 0
2) 𝑦 > 0
3) 𝑥𝑦 ≤ 𝑃
• That is, we can always find a nonempty string y not too far from the beginning of S that can be
“pumped”, that is, repeating y any number of times, or deleting it (the case i=0), keeps the resulting
string in the language L.
PROOF:
• Suppose L is regular. Then, L=L(A) for some DFA A.
• Suppose A has n states.
• Now consider any string 𝑤 of length 𝑛 or more, say 𝑤 = 𝑎1𝑎2 … . 𝑎𝑚, where 𝑚 ≥
𝑛, and each 𝑎𝑖 is an input symbol.
• For 𝑖 = 0,1,2, … . , 𝑛, define state 𝑝𝑖 to be መ
𝛿 𝑞0, 𝑎1𝑎2 … 𝑎𝑖 , where 𝛿 is the
transition function of 𝐴 and 𝑞0 is the start state of 𝐴. That is, 𝑝𝑖 is the state 𝐴 is in after
reading the first 𝑖 symbols of 𝑤.
• Note that 𝑝0 = 𝑞0.
• By the pigeonhole principle, it is not possible for the n+1 different 𝑝𝑖’s for 𝑖 =
0,1,2, … . , 𝑛 to be distinct, since there are only 𝑛 different states.
• Thus, we can find two different integers i and j, with 0 ≤ 𝑖 < 𝑗 ≤ 𝑛, such that 𝑝𝑖 = 𝑝𝑗.
• Now, we can break 𝑤 = 𝑥𝑦𝑧 as follows:
1. x = 𝑎1𝑎2 … . 𝑎𝑖
2. 𝑦 = 𝑎𝑖+1𝑎𝑖+2 … 𝑎𝑗
3. 𝑧 = 𝑎𝑗+1𝑎𝑗+2 … 𝑎𝑚
• That is, 𝑥 takes us to 𝑝𝑖 once; 𝑦 takes us from 𝑝𝑖 back to 𝑝𝑖 (since 𝑝𝑖 is also 𝑝𝑗), and 𝑧 is the balance of 𝑤.
• The relationships among the strings and states are suggested by Fig.
Every string longer than the number of states must cause a state to repeat
• Note that 𝑥 may be empty, in the case that 𝑖 = 0. Also, z may be empty if 𝑗 = 𝑛 = 𝑚.
• However, 𝑦 cannot be empty, since 𝑖 is strictly less than 𝑗.
• Now, consider what happens if the automaton 𝐴 receives the input 𝑥𝑦𝑘𝑧, for any
𝑘 ≥ 0.
• If 𝑘 = 0, then the automaton goes from the start state 𝑞0 (which is also 𝑝0) to
𝑝𝑖 on input 𝑥.
• Since 𝑝𝑖 is also 𝑝𝑗, it must be that 𝐴 goes from 𝑝𝑖 to the accepting state shown in
Figure on input 𝑧. Thus, A accepts 𝑥𝑧.
• If 𝑘 > 0, then 𝐴 goes from 𝑞0 to 𝑝𝑖 on input 𝑥 circles from 𝑝𝑖 to 𝑝𝑖 𝑘 times on
input 𝑦𝑘, and then goes to the accepting state on input 𝑧.
• Thus, for any 𝑘 ≥ 0 , 𝑥𝑦𝑘
𝑧 is also accepted by 𝐴; that is, 𝑥𝑦𝑘
𝑧 is in 𝐿.
1. Prove that the language L = {0n1n: n>0} is non-regular using pumping lemma
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 0𝑝
1𝑝
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Since 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠.
Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 0𝑝−𝛼−𝛽
1𝑝
i. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
0𝑝−𝛼−𝛽
1𝑝
= 0𝑝+𝛽(𝑖−1)
1𝑝
This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 = p
i.e., 𝛽 𝑖 − 1 = 0
𝑖 − 1 = 0
𝑖 = 1
Therefore, if 𝑖 ≠ 1, 𝑥𝑦𝑖
𝑧 ∉ 𝐿, and hence, L is not regular.
Example for contradiction:
Let 𝑝 = 2, 𝑖 = 2
𝑤 = 0011
Let 𝑥 = 0, 𝑦 = 0 and then, 𝑧 = 11
𝑥𝑦𝑖
𝑧 =00011 ∉ 𝐿
2. Prove that the language L = {strings having same no. of 0s and 1s} is non-regular using pumping lemma
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 0𝑝
1𝑝
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Since 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠.
Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 0𝑝−𝛼−𝛽
1𝑝
i. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
0𝑝−𝛼−𝛽
1𝑝
= 0𝑝+𝛽(𝑖−1)
1𝑝
This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 = p
i.e., 𝛽 𝑖 − 1 = 0
𝑖 − 1 = 0
𝑖 = 1
Therefore, if 𝑖 ≠ 1, 𝑥𝑦𝑖
𝑧 ∉ 𝐿 and hence, L is not regular
3. Prove that the language L = {strings having more no. of 1s than 0s} is non-regular using pumping lemma
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 0𝑝
1𝑝+1
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Since 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠.
Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 0𝑝−𝛼−𝛽
1𝑝+1
vi. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
0𝑝−𝛼−𝛽
1𝑝+1
= 0𝑝+𝛽(𝑖−1)
1𝑝+1
This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 < p + 1
i.e., 𝛽 𝑖 − 1 < 1
𝑖 − 1 < 1
𝑖 = 0 or 1
Therefore, if 𝑖 ≠ 1 𝑜𝑟 𝑖 ≠ 0, 𝑥𝑦𝑖
𝑧 ∉ 𝐿 and hence L is not regular. (Verify using i=2)
4. Prove that the language L = {𝟎𝟐𝒏
𝟏𝒏
: 𝒏 ≥ 𝟎} is non-regular using pumping lemma
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 02𝑝
1𝑝
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Since 𝑤 has 2𝑝 zeros and 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠.
Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 02𝑝−𝛼−𝛽
1𝑝
i. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
02𝑝−𝛼−𝛽
1𝑝
= 02𝑝+𝛽(𝑖−1)
1𝑝
This string belongs to L only if: 2𝑝 + 𝛽 𝑖 − 1 = 2𝑝
i.e., 𝛽 𝑖 − 1 = 0
𝑖 − 1 = 0
𝑖 = 1
Therefore, if 𝑖 ≠ 1, 𝑥𝑦𝑖
𝑧 ∉ 𝐿 and hence L is not regular
5. Prove that the language L = {strings having no. of zeros as a perfect square i.e. 𝟎𝒏𝟐
} is non-regular using pumping lemma (No. of zeros =0, 2, 4, 9,…)
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 0𝑝2
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 0𝑝2−𝛼−𝛽
i. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
0𝑝2−𝛼−𝛽
= 0𝑝2+𝛽(𝑖−1)
This string belongs to L only if: 𝑝2
+ 𝛽 𝑖 − 1 is a perfect square
Let 𝑖 = 2, then 𝑝2
+ 𝛽 should be a perfect square.
𝑝2
< 𝑝2
+ 𝛽 𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1 ≤ 𝑝2
+ 𝑝 (𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝) < (𝑝 + 1)2
Therefore, 𝑝2
+ 𝛽 is not a perfect square and , 𝑥𝑦𝑖
𝑧 ∉ 𝐿 (Verify using i=2)
5. Prove that the language L = {strings that are not palindrome} is non-regular using pumping lemma (Example: 𝒂𝒃𝒃 ∈ 𝑳, 𝒃𝒂𝒃 ∉ 𝑳 )
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 0𝑝
110𝑝+𝑝!
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 0𝑝−𝛼−𝛽
110𝑝+𝑝!
i. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
0𝑝−𝛼−𝛽
110𝑝+𝑝!
= 0𝑝+𝛽(𝑖−1)
110𝑝+𝑝!
This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 ≠ 𝑝 + 𝑝!
𝛽 𝑖 − 1 ≠ 𝑝!
𝑖 ≠
𝑝!
𝛽
+ 1
Since 1 ≤ 𝛽 ≤ 𝑝,
𝑝!
𝛽
𝑖𝑠 𝑎𝑛 𝑖𝑛𝑡𝑒𝑔𝑒𝑟
Therefore, if 𝑖 =
𝑝!
𝛽
+ 1 , 𝑥𝑦𝑖
𝑧 ∉ 𝐿
5. Prove that the language L = {strings with no. of zeros is a factorial} is non-regular using pumping lemma (No. of zeros =0, 1, 2, 6, 24,…)
Proof:
i. Suppose 𝐿 is regular
ii. Let pumping length of 𝐿 be 𝑝
iii. Choose 𝑤 = 0𝑝!
iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that:
a) 𝑥𝑦 ≤ 𝑝
b) 𝑦 ≥ 1
Third condition can be used to get the contradiction
v. Let 𝑥 = 0∝
, 𝛼 ≥ 0;
𝑦 = 0𝛽
, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝;
𝑧 = 0𝑝!−𝛼−𝛽
i. Choose an 𝑖 such that 𝑥𝑦𝑖
𝑧 ∉ 𝐿
𝑥𝑦𝑖
𝑧 = 0𝛼
0𝑖𝛽
0𝑝!−𝛼−𝛽
= 0𝑝!+𝛽(𝑖−1)
This string belongs to L only if: 𝑝! + 𝛽 𝑖 − 1 is a factorial
Let i=2, 𝑝! + 𝛽 should be a factorial
𝑝! < 𝑝! + 𝛽 𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1 ≤ 𝑝! + 𝑝(𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝) < 𝑝 + 1 !
Therefore, 𝑝! + 𝛽 is not a factorial, 𝑎𝑛𝑑 𝑥𝑦𝑖
𝑧 ∉ 𝐿
To prove that a language is not regular using Pumping Lemma, follow the below steps:
• We prove using contradiction.
• Assume that L is regular.
• It has to have a pumping length (say P)
• All strings longer than P can be pumped 𝑆 ≥ 𝑃.
• Now find a string ‘S’ in L such that 𝑆 ≥ 𝑃.
• Divide S into xyz
• Show that 𝑥𝑦𝑖
𝑧 ∉ 𝐿 for some 𝑖.
• S cannot be pumped == CONTRADICTION
Myhill Nerode Theorem
• The Myhill Nerode theorem is a fundamental result coming down to
the theory of languages.
• This theory was proven by John Myhill and Anil Nerode in 1958.
• It is used to prove whether or not a language L is regular and it is also
used for minimization of states in DFA.
• To understand this theorem, first we need to understand
what Indistinguishability(or equivalence) is :
• Given a language L and x,y are strings over ∑*, if for every string z ∈
∑*, xz, yz ∈ L or xz, yz ∉ L then x and y are said to be
indistinguishable over language L.
• Formally, we denote that x and y are indistinguishable over L by the
following notation : x ≡L y.
• ≡L partitions ∑* into disjoint sets called equivalence classes.
•
• Myhill Nerode Theorem :
• A language is regular if and only if ≡L partitions ∑* into finitely many
equivalence classes. If ≡L partitions ∑* into n equivalence classes, then a
minimal DFA recognizing L has exactly n states.
• If there are infinitely many equivalence classes, that means the DFA has
infinite no. of states, which is not realizable. i.e., we cannot define an
automata to accept that language and hence the language is not regular.
• Example : To prove that L = {anbn | n ≥ 0} is not regular.
• We can show that L has infinitely many equivalence classes by showing that
ak and ai are distinguishable by L whenever k ≠ i.
• Thus, for x = ak and y = ai we let z = bk. Then xz = akbk is in the language but
yz = aibk is not.
• Thus, each equivalence class of L can contain at most one string of the form
ai so there must be infinitely many equivalence classes.
• That means L is not regular by the Myhill Nerode theorem.
Myhill-Nerode Theorem
(Minimization of DFA – Table Filling Method)
STEPS:
1. Draw a table for all pairs of states (𝑃, 𝑄).
2. Mark all pairs where 𝑃 ∈ 𝐹 and 𝑄 ∉ 𝐹, where
𝐹 is the set of final states.
3. If there are any unmarked pairs (𝑃, 𝑄) such that
[𝛿 𝑃, 𝑥 , 𝛿 𝑄, 𝑥 ] is marked, then mark
𝑃, 𝑄 where 𝑥 is an input symbol.
4. Repeat this until no more markings can be made.
5. Combine all the unmarked pairs and make them a
single state in the minimized DFA.
A B C D E F
A
B
C
D
E
F
A B C D E F
A
B
C
D
E
F
Step 2. Mark all pairs where 𝑃 ∈ 𝐹 and 𝑄 ∉ 𝐹, where 𝐹 is the set of final states. (In this case {C, D, E} are the final states and {A,B,F} are the
non final states.
Step3: If there are any unmarked pairs (𝑃, 𝑄) such that [𝛿 𝑃, 𝑥 , 𝛿 𝑄, 𝑥 ] is marked, then mark 𝑃, 𝑄 where 𝑥 is an input symbol.
1) (B,A) : 𝛿 𝐴, 0 → 𝐵, 𝛿(𝐴, 1) → 𝐶
𝛿 𝐵, 0 → 𝐴, 𝛿(𝐵, 1) → 𝐷
2) (D,C) : 𝛿 𝐷, 0 → 𝐸, 𝛿(𝐷, 1) → 𝐹
𝛿 𝐶, 0 → 𝐸, 𝛿(𝐶, 1) → 𝐹
3) (E,C) : 𝛿 𝐸, 0 → 𝐸, 𝛿(𝐸, 1) → 𝐹
𝛿 𝐶, 0 → 𝐸, 𝛿 𝐶, 1 → 𝐹
4) (E,D) : 𝛿 𝐸, 0 → 𝐸, 𝛿(𝐸, 1) → 𝐹
𝛿 𝐷, 0 → 𝐸, 𝛿 𝐷, 1 → 𝐹
5) (F,A) : 𝛿 𝐹, 0 → 𝐹, 𝛿(𝐹, 1) → 𝐹
𝛿 𝐴, 0 → 𝐵 𝛿(𝐴, 1) → 𝐶
6) (F,B) : 𝛿 𝐹, 0 → 𝐹, 𝛿 𝐹, 1 → 𝐹
𝛿 𝐵, 0 → 𝐴, 𝛿(𝐴, 1) → 𝐶
• Final unmarked states are: {B,A}, {D,C}, {E,C}, {E,D}
• Final minimized DFA:
Minimize the given DFA using Myhill-Nerode theorem
A B C D E
A
B ✓
C
D
E
A B C D E
A
B ✓
C ✓
D
E
A B C D E
A
B ✓
C ✓
D ✓
E
A B C D E
A
B ✓
C ✓
D ✓
E ✓
A B C D E
A
B ✓
C ✓
D ✓
E ✓ ✓
A B C D E
A
B ✓
C ✓
D ✓
E ✓ ✓ ✓
• If there are any unmarked pairs (𝑃, 𝑄) such that [𝛿 𝑃, 𝑥 , 𝛿 𝑄, 𝑥 ] is marked, then mark 𝑃, 𝑄 where 𝑥 is an input symbol.
1) (C,A) : 𝛿 𝐶, 0 → 𝐵, 𝛿(𝐶, 1) → 𝐶
𝛿 𝐴, 0 → 𝐵, 𝛿(𝐴, 1) → 𝐶
2) (D,A) : 𝛿 𝐷, 0 → 𝐵, 𝛿 𝐷, 1 → 𝐸
𝛿 𝐴, 0 → 𝐵, 𝛿(𝐴, 1) → 𝐶
4) (E,B) : 𝛿 𝐸, 0 → 𝐵, 𝛿(𝐸, 1) → 𝐶
𝛿 𝐵, 0 → 𝐵, 𝛿(𝐵, 1) → 𝐷
5) Final unmarked states are: {A,C}, {B}, {D}, {E} and minimized DFA is given by:
3) (D,C) : 𝛿 𝐷, 0 → 𝐵, 𝛿 𝐷, 1 → 𝐸
𝛿 𝐶, 0 → 𝐵, 𝛿(𝐶, 1) → 𝐶
A B C D E
A
B ✓
C ✓
D ✓
E ✓ ✓ ✓

More Related Content

PDF
Chapter 3 REGULAR EXPRESSION.pdf
PPTX
Pumping lemma for regular set h1
PPT
hop-chap4.ppt
PPTX
WINSEM2022-23_CSI2005_TH_VL2022230504110_Reference_Material_II_22-12-2022_1.2...
PDF
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
PPTX
AUTOMATA AUTOMATA Automata5Chapter4.pptx
PDF
Lecture-8-Pumpdndndndndnddndning Lemma.pdf
PPTX
10 Regular VS Non Regular Language.pptx
Chapter 3 REGULAR EXPRESSION.pdf
Pumping lemma for regular set h1
hop-chap4.ppt
WINSEM2022-23_CSI2005_TH_VL2022230504110_Reference_Material_II_22-12-2022_1.2...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
AUTOMATA AUTOMATA Automata5Chapter4.pptx
Lecture-8-Pumpdndndndndnddndning Lemma.pdf
10 Regular VS Non Regular Language.pptx

Similar to 09.LearningMaterial_Sample.pdf (20)

PDF
Mba ebooks ! Edhole
PDF
Free Ebooks Download ! Edhole
PDF
Mean value theorem
PPTX
RegularLanguageProperties.pptx
PPT
Formal Languages and regular langugaes IN FLAG
DOCX
Regular Expression .docx
PPTX
Mod 2_RegularExpressions.pptx
PDF
Automata
PDF
Automata
PPTX
Chapter 4_Regular Expressions in Automata.pptx
PPTX
Teorema balzano weierstrass
PDF
Flat unit 2
PDF
F_Autómatas_MIT_2010--------------------
PDF
Uniform Boundedness of Shift Operators
PPTX
Chapter Two - Regular Expression and Regular languages.pptx
PPTX
Infinite Series Presentation by Jatin Dhola
PDF
Formal Languages and Automata Theory unit 2
PPTX
pumpexamples.pptx
PDF
Lex analysis
PDF
practice-final-soln.pdf
Mba ebooks ! Edhole
Free Ebooks Download ! Edhole
Mean value theorem
RegularLanguageProperties.pptx
Formal Languages and regular langugaes IN FLAG
Regular Expression .docx
Mod 2_RegularExpressions.pptx
Automata
Automata
Chapter 4_Regular Expressions in Automata.pptx
Teorema balzano weierstrass
Flat unit 2
F_Autómatas_MIT_2010--------------------
Uniform Boundedness of Shift Operators
Chapter Two - Regular Expression and Regular languages.pptx
Infinite Series Presentation by Jatin Dhola
Formal Languages and Automata Theory unit 2
pumpexamples.pptx
Lex analysis
practice-final-soln.pdf
Ad

More from ssuser47f7f2 (10)

PPT
rs1.ppt
PPT
Lecture7x.ppt
PPT
NORMAL-FORMS.ppt
PPTX
functions (1).pptx
PPTX
Module 2_Conditional Statements.pptx
PPTX
03-FiniteAutomata.pptx
PPT
15159222.ppt
PPT
FiniteAutomata (1).ppt
PPTX
Module 1-System Software PROGRAMS.pptx
PDF
module1 network security.pdf
rs1.ppt
Lecture7x.ppt
NORMAL-FORMS.ppt
functions (1).pptx
Module 2_Conditional Statements.pptx
03-FiniteAutomata.pptx
15159222.ppt
FiniteAutomata (1).ppt
Module 1-System Software PROGRAMS.pptx
module1 network security.pdf
Ad

Recently uploaded (20)

PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
737-MAX_SRG.pdf student reference guides
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PPT
Occupational Health and Safety Management System
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
communication and presentation skills 01
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Soil Improvement Techniques Note - Rabbi
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
"Array and Linked List in Data Structures with Types, Operations, Implementat...
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
737-MAX_SRG.pdf student reference guides
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
distributed database system" (DDBS) is often used to refer to both the distri...
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Occupational Health and Safety Management System
III.4.1.2_The_Space_Environment.p pdffdf
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Safety Seminar civil to be ensured for safe working.
communication and presentation skills 01
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Abrasive, erosive and cavitation wear.pdf
Soil Improvement Techniques Note - Rabbi
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf

09.LearningMaterial_Sample.pdf

  • 1. FORMAL LANGUAGES & AUTOMATA THEORY MODULE 2 PRIYA MARIAM RAJU ASSISTANT PROFESSOR DEPARTMENT OF INFORMATION TECHNOLOGY RAJAGIRI SCHOOL OF ENGINEERING & TECHNOLOGY
  • 2. Converting Regular Expressions to Automata The basis of the construction of an automaton from a regular expression
  • 3. (a) R + S (b) RS (c) R*
  • 4. 1. Convert the Regular Expression (0+1)*1(0+1) to an epsilon NFA
  • 5. 2. Convert the Regular expression 01 + 101 to an epsilon NFA
  • 6. 3. Convert the Regular expression (a+b)*a to an epsilon NFA
  • 7. 3. Convert the Regular expression a + ba* to an epsilon NFA
  • 8. Regular Expressions to NFA • a + b • ab • a* A B a, b A B C a b A a
  • 9. Convert the regular expression ba*b to NFA • L = {bb, bab, baab,…}
  • 10. Convert the regular expression (a+b)c to NFA
  • 11. Convert the regular expression a(bc)* to NFA L = {a, abc, abcbc,….}
  • 12. Convert the regular expression 10 = (0+11)0*1
  • 13. Conversion of Automata to Regular Expressions – State Elimination Method • Rule 1: If there are incoming transitions to the initial state, to get rid of incoming edges make a new start state with no incoming edges and an outgoing edge to the old start state with Ɛ-transition. The initial state before is now normal state with added incoming Ɛ-transition.
  • 14. Conversion of DFA to Regular Expressions – State Elimination Method • Rule-2 : If there are outgoing transitions from final state, to get rid of outgoing edges make a new final state with no outgoing edges and an incoming edge from old final state of Ɛ- transition. Old final state is transformed into normal state with the added transition of Ɛ.
  • 15. Conversion of DFA to Regular Expressions – State Elimination Method • Rule-3 : If the Automata have multiple final states it is recommended to strip their status of being final states and add outgoing Ɛ-transition to new and only final state with no outgoing transitions.
  • 16. Rule 4: Eliminating intermediate states 1 2 3 a b 1 3 ab b 1 2 a 1 3 a+b 1 a 2 b 1 2 a*b
  • 17. 1. Convert the given DFA to regular expression by state elimination method
  • 18. 2. Convert the given DFA to regular expression by state elimination method (DFA with multiple final states)
  • 19. 3. Convert the given DFA to regular expression by state elimination method
  • 20. 4. Convert the given DFA to regular expression by state elimination method
  • 21. Proving Languages Not to Be Regular • We have established that the class of languages known as the regular languages has at least four different descriptions. • They are the languages accepted by DFAs, by NFAs and by ϵ-NFAs and they are also the languages defined by regular expressions. • Not every language is a regular language. • In this section we shall introduce a powerful technique known as the pumping lemma for showing certain languages not to be regular.
  • 22. The Pumping Lemma for Regular Languages • Pumping Lemma is used to prove that a language is NOT REGULAR. • It cannot be used to prove that a language is REGULAR. • THEOREM: If L is a regular language, then L has a pumping length ‘P’ such that any string S where |S|>=P may be divided into 3 parts S = xyz such that the following conditions must be true: 1) 𝑥𝑦𝑖𝑧 ∈ 𝐿 for every 𝑖 ≥ 0 2) 𝑦 > 0 3) 𝑥𝑦 ≤ 𝑃 • That is, we can always find a nonempty string y not too far from the beginning of S that can be “pumped”, that is, repeating y any number of times, or deleting it (the case i=0), keeps the resulting string in the language L.
  • 23. PROOF: • Suppose L is regular. Then, L=L(A) for some DFA A. • Suppose A has n states. • Now consider any string 𝑤 of length 𝑛 or more, say 𝑤 = 𝑎1𝑎2 … . 𝑎𝑚, where 𝑚 ≥ 𝑛, and each 𝑎𝑖 is an input symbol. • For 𝑖 = 0,1,2, … . , 𝑛, define state 𝑝𝑖 to be መ 𝛿 𝑞0, 𝑎1𝑎2 … 𝑎𝑖 , where 𝛿 is the transition function of 𝐴 and 𝑞0 is the start state of 𝐴. That is, 𝑝𝑖 is the state 𝐴 is in after reading the first 𝑖 symbols of 𝑤. • Note that 𝑝0 = 𝑞0. • By the pigeonhole principle, it is not possible for the n+1 different 𝑝𝑖’s for 𝑖 = 0,1,2, … . , 𝑛 to be distinct, since there are only 𝑛 different states. • Thus, we can find two different integers i and j, with 0 ≤ 𝑖 < 𝑗 ≤ 𝑛, such that 𝑝𝑖 = 𝑝𝑗.
  • 24. • Now, we can break 𝑤 = 𝑥𝑦𝑧 as follows: 1. x = 𝑎1𝑎2 … . 𝑎𝑖 2. 𝑦 = 𝑎𝑖+1𝑎𝑖+2 … 𝑎𝑗 3. 𝑧 = 𝑎𝑗+1𝑎𝑗+2 … 𝑎𝑚 • That is, 𝑥 takes us to 𝑝𝑖 once; 𝑦 takes us from 𝑝𝑖 back to 𝑝𝑖 (since 𝑝𝑖 is also 𝑝𝑗), and 𝑧 is the balance of 𝑤. • The relationships among the strings and states are suggested by Fig. Every string longer than the number of states must cause a state to repeat • Note that 𝑥 may be empty, in the case that 𝑖 = 0. Also, z may be empty if 𝑗 = 𝑛 = 𝑚. • However, 𝑦 cannot be empty, since 𝑖 is strictly less than 𝑗.
  • 25. • Now, consider what happens if the automaton 𝐴 receives the input 𝑥𝑦𝑘𝑧, for any 𝑘 ≥ 0. • If 𝑘 = 0, then the automaton goes from the start state 𝑞0 (which is also 𝑝0) to 𝑝𝑖 on input 𝑥. • Since 𝑝𝑖 is also 𝑝𝑗, it must be that 𝐴 goes from 𝑝𝑖 to the accepting state shown in Figure on input 𝑧. Thus, A accepts 𝑥𝑧. • If 𝑘 > 0, then 𝐴 goes from 𝑞0 to 𝑝𝑖 on input 𝑥 circles from 𝑝𝑖 to 𝑝𝑖 𝑘 times on input 𝑦𝑘, and then goes to the accepting state on input 𝑧. • Thus, for any 𝑘 ≥ 0 , 𝑥𝑦𝑘 𝑧 is also accepted by 𝐴; that is, 𝑥𝑦𝑘 𝑧 is in 𝐿.
  • 26. 1. Prove that the language L = {0n1n: n>0} is non-regular using pumping lemma Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 0𝑝 1𝑝 iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Since 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 0𝑝−𝛼−𝛽 1𝑝 i. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 0𝑝−𝛼−𝛽 1𝑝 = 0𝑝+𝛽(𝑖−1) 1𝑝 This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 = p i.e., 𝛽 𝑖 − 1 = 0 𝑖 − 1 = 0 𝑖 = 1 Therefore, if 𝑖 ≠ 1, 𝑥𝑦𝑖 𝑧 ∉ 𝐿, and hence, L is not regular. Example for contradiction: Let 𝑝 = 2, 𝑖 = 2 𝑤 = 0011 Let 𝑥 = 0, 𝑦 = 0 and then, 𝑧 = 11 𝑥𝑦𝑖 𝑧 =00011 ∉ 𝐿
  • 27. 2. Prove that the language L = {strings having same no. of 0s and 1s} is non-regular using pumping lemma Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 0𝑝 1𝑝 iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Since 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 0𝑝−𝛼−𝛽 1𝑝 i. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 0𝑝−𝛼−𝛽 1𝑝 = 0𝑝+𝛽(𝑖−1) 1𝑝 This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 = p i.e., 𝛽 𝑖 − 1 = 0 𝑖 − 1 = 0 𝑖 = 1 Therefore, if 𝑖 ≠ 1, 𝑥𝑦𝑖 𝑧 ∉ 𝐿 and hence, L is not regular
  • 28. 3. Prove that the language L = {strings having more no. of 1s than 0s} is non-regular using pumping lemma Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 0𝑝 1𝑝+1 iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Since 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 0𝑝−𝛼−𝛽 1𝑝+1 vi. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 0𝑝−𝛼−𝛽 1𝑝+1 = 0𝑝+𝛽(𝑖−1) 1𝑝+1 This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 < p + 1 i.e., 𝛽 𝑖 − 1 < 1 𝑖 − 1 < 1 𝑖 = 0 or 1 Therefore, if 𝑖 ≠ 1 𝑜𝑟 𝑖 ≠ 0, 𝑥𝑦𝑖 𝑧 ∉ 𝐿 and hence L is not regular. (Verify using i=2)
  • 29. 4. Prove that the language L = {𝟎𝟐𝒏 𝟏𝒏 : 𝒏 ≥ 𝟎} is non-regular using pumping lemma Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 02𝑝 1𝑝 iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Since 𝑤 has 2𝑝 zeros and 𝑥𝑦 ≤ 𝑝, 𝑥𝑦 contains only 0𝑠 and no 1𝑠. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 02𝑝−𝛼−𝛽 1𝑝 i. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 02𝑝−𝛼−𝛽 1𝑝 = 02𝑝+𝛽(𝑖−1) 1𝑝 This string belongs to L only if: 2𝑝 + 𝛽 𝑖 − 1 = 2𝑝 i.e., 𝛽 𝑖 − 1 = 0 𝑖 − 1 = 0 𝑖 = 1 Therefore, if 𝑖 ≠ 1, 𝑥𝑦𝑖 𝑧 ∉ 𝐿 and hence L is not regular
  • 30. 5. Prove that the language L = {strings having no. of zeros as a perfect square i.e. 𝟎𝒏𝟐 } is non-regular using pumping lemma (No. of zeros =0, 2, 4, 9,…) Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 0𝑝2 iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 0𝑝2−𝛼−𝛽 i. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 0𝑝2−𝛼−𝛽 = 0𝑝2+𝛽(𝑖−1) This string belongs to L only if: 𝑝2 + 𝛽 𝑖 − 1 is a perfect square Let 𝑖 = 2, then 𝑝2 + 𝛽 should be a perfect square. 𝑝2 < 𝑝2 + 𝛽 𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1 ≤ 𝑝2 + 𝑝 (𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝) < (𝑝 + 1)2 Therefore, 𝑝2 + 𝛽 is not a perfect square and , 𝑥𝑦𝑖 𝑧 ∉ 𝐿 (Verify using i=2)
  • 31. 5. Prove that the language L = {strings that are not palindrome} is non-regular using pumping lemma (Example: 𝒂𝒃𝒃 ∈ 𝑳, 𝒃𝒂𝒃 ∉ 𝑳 ) Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 0𝑝 110𝑝+𝑝! iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 0𝑝−𝛼−𝛽 110𝑝+𝑝! i. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 0𝑝−𝛼−𝛽 110𝑝+𝑝! = 0𝑝+𝛽(𝑖−1) 110𝑝+𝑝! This string belongs to L only if: 𝑝 + 𝛽 𝑖 − 1 ≠ 𝑝 + 𝑝! 𝛽 𝑖 − 1 ≠ 𝑝! 𝑖 ≠ 𝑝! 𝛽 + 1 Since 1 ≤ 𝛽 ≤ 𝑝, 𝑝! 𝛽 𝑖𝑠 𝑎𝑛 𝑖𝑛𝑡𝑒𝑔𝑒𝑟 Therefore, if 𝑖 = 𝑝! 𝛽 + 1 , 𝑥𝑦𝑖 𝑧 ∉ 𝐿
  • 32. 5. Prove that the language L = {strings with no. of zeros is a factorial} is non-regular using pumping lemma (No. of zeros =0, 1, 2, 6, 24,…) Proof: i. Suppose 𝐿 is regular ii. Let pumping length of 𝐿 be 𝑝 iii. Choose 𝑤 = 0𝑝! iv. Look at every possible decomposition of 𝑤 into 𝑥𝑦𝑧 such that: a) 𝑥𝑦 ≤ 𝑝 b) 𝑦 ≥ 1 Third condition can be used to get the contradiction v. Let 𝑥 = 0∝ , 𝛼 ≥ 0; 𝑦 = 0𝛽 , 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝; 𝑧 = 0𝑝!−𝛼−𝛽 i. Choose an 𝑖 such that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 𝑥𝑦𝑖 𝑧 = 0𝛼 0𝑖𝛽 0𝑝!−𝛼−𝛽 = 0𝑝!+𝛽(𝑖−1) This string belongs to L only if: 𝑝! + 𝛽 𝑖 − 1 is a factorial Let i=2, 𝑝! + 𝛽 should be a factorial 𝑝! < 𝑝! + 𝛽 𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1 ≤ 𝑝! + 𝑝(𝑠𝑖𝑛𝑐𝑒, 𝛽 ≥ 1; 𝛼 + 𝛽 ≤ 𝑝) < 𝑝 + 1 ! Therefore, 𝑝! + 𝛽 is not a factorial, 𝑎𝑛𝑑 𝑥𝑦𝑖 𝑧 ∉ 𝐿
  • 33. To prove that a language is not regular using Pumping Lemma, follow the below steps: • We prove using contradiction. • Assume that L is regular. • It has to have a pumping length (say P) • All strings longer than P can be pumped 𝑆 ≥ 𝑃. • Now find a string ‘S’ in L such that 𝑆 ≥ 𝑃. • Divide S into xyz • Show that 𝑥𝑦𝑖 𝑧 ∉ 𝐿 for some 𝑖. • S cannot be pumped == CONTRADICTION
  • 34. Myhill Nerode Theorem • The Myhill Nerode theorem is a fundamental result coming down to the theory of languages. • This theory was proven by John Myhill and Anil Nerode in 1958. • It is used to prove whether or not a language L is regular and it is also used for minimization of states in DFA. • To understand this theorem, first we need to understand what Indistinguishability(or equivalence) is : • Given a language L and x,y are strings over ∑*, if for every string z ∈ ∑*, xz, yz ∈ L or xz, yz ∉ L then x and y are said to be indistinguishable over language L. • Formally, we denote that x and y are indistinguishable over L by the following notation : x ≡L y. • ≡L partitions ∑* into disjoint sets called equivalence classes. • • Myhill Nerode Theorem : • A language is regular if and only if ≡L partitions ∑* into finitely many equivalence classes. If ≡L partitions ∑* into n equivalence classes, then a minimal DFA recognizing L has exactly n states. • If there are infinitely many equivalence classes, that means the DFA has infinite no. of states, which is not realizable. i.e., we cannot define an automata to accept that language and hence the language is not regular. • Example : To prove that L = {anbn | n ≥ 0} is not regular. • We can show that L has infinitely many equivalence classes by showing that ak and ai are distinguishable by L whenever k ≠ i. • Thus, for x = ak and y = ai we let z = bk. Then xz = akbk is in the language but yz = aibk is not. • Thus, each equivalence class of L can contain at most one string of the form ai so there must be infinitely many equivalence classes. • That means L is not regular by the Myhill Nerode theorem.
  • 35. Myhill-Nerode Theorem (Minimization of DFA – Table Filling Method) STEPS: 1. Draw a table for all pairs of states (𝑃, 𝑄). 2. Mark all pairs where 𝑃 ∈ 𝐹 and 𝑄 ∉ 𝐹, where 𝐹 is the set of final states. 3. If there are any unmarked pairs (𝑃, 𝑄) such that [𝛿 𝑃, 𝑥 , 𝛿 𝑄, 𝑥 ] is marked, then mark 𝑃, 𝑄 where 𝑥 is an input symbol. 4. Repeat this until no more markings can be made. 5. Combine all the unmarked pairs and make them a single state in the minimized DFA. A B C D E F A B C D E F A B C D E F A B C D E F
  • 36. Step 2. Mark all pairs where 𝑃 ∈ 𝐹 and 𝑄 ∉ 𝐹, where 𝐹 is the set of final states. (In this case {C, D, E} are the final states and {A,B,F} are the non final states.
  • 37. Step3: If there are any unmarked pairs (𝑃, 𝑄) such that [𝛿 𝑃, 𝑥 , 𝛿 𝑄, 𝑥 ] is marked, then mark 𝑃, 𝑄 where 𝑥 is an input symbol. 1) (B,A) : 𝛿 𝐴, 0 → 𝐵, 𝛿(𝐴, 1) → 𝐶 𝛿 𝐵, 0 → 𝐴, 𝛿(𝐵, 1) → 𝐷 2) (D,C) : 𝛿 𝐷, 0 → 𝐸, 𝛿(𝐷, 1) → 𝐹 𝛿 𝐶, 0 → 𝐸, 𝛿(𝐶, 1) → 𝐹 3) (E,C) : 𝛿 𝐸, 0 → 𝐸, 𝛿(𝐸, 1) → 𝐹 𝛿 𝐶, 0 → 𝐸, 𝛿 𝐶, 1 → 𝐹 4) (E,D) : 𝛿 𝐸, 0 → 𝐸, 𝛿(𝐸, 1) → 𝐹 𝛿 𝐷, 0 → 𝐸, 𝛿 𝐷, 1 → 𝐹 5) (F,A) : 𝛿 𝐹, 0 → 𝐹, 𝛿(𝐹, 1) → 𝐹 𝛿 𝐴, 0 → 𝐵 𝛿(𝐴, 1) → 𝐶 6) (F,B) : 𝛿 𝐹, 0 → 𝐹, 𝛿 𝐹, 1 → 𝐹 𝛿 𝐵, 0 → 𝐴, 𝛿(𝐴, 1) → 𝐶
  • 38. • Final unmarked states are: {B,A}, {D,C}, {E,C}, {E,D} • Final minimized DFA:
  • 39. Minimize the given DFA using Myhill-Nerode theorem A B C D E A B ✓ C D E A B C D E A B ✓ C ✓ D E A B C D E A B ✓ C ✓ D ✓ E A B C D E A B ✓ C ✓ D ✓ E ✓ A B C D E A B ✓ C ✓ D ✓ E ✓ ✓ A B C D E A B ✓ C ✓ D ✓ E ✓ ✓ ✓
  • 40. • If there are any unmarked pairs (𝑃, 𝑄) such that [𝛿 𝑃, 𝑥 , 𝛿 𝑄, 𝑥 ] is marked, then mark 𝑃, 𝑄 where 𝑥 is an input symbol. 1) (C,A) : 𝛿 𝐶, 0 → 𝐵, 𝛿(𝐶, 1) → 𝐶 𝛿 𝐴, 0 → 𝐵, 𝛿(𝐴, 1) → 𝐶 2) (D,A) : 𝛿 𝐷, 0 → 𝐵, 𝛿 𝐷, 1 → 𝐸 𝛿 𝐴, 0 → 𝐵, 𝛿(𝐴, 1) → 𝐶 4) (E,B) : 𝛿 𝐸, 0 → 𝐵, 𝛿(𝐸, 1) → 𝐶 𝛿 𝐵, 0 → 𝐵, 𝛿(𝐵, 1) → 𝐷 5) Final unmarked states are: {A,C}, {B}, {D}, {E} and minimized DFA is given by: 3) (D,C) : 𝛿 𝐷, 0 → 𝐵, 𝛿 𝐷, 1 → 𝐸 𝛿 𝐶, 0 → 𝐵, 𝛿(𝐶, 1) → 𝐶 A B C D E A B ✓ C ✓ D ✓ E ✓ ✓ ✓