You are on page 1of 8

Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.

pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

(Week 11) Lecture 21-22


Objectives: Learning objectives of this lecture are

 FA Operations
o 𝑭𝑨𝟏 − 𝑭𝑨𝟐
o Complement
Text Book &Resources:Introduction to Computer Theory–2nd Edition - (I. O. Cohen)

L1=Language of all words which end with "a"


={a,aa,ba,aaa,aba,bba,baa,aaaa,abba,baaa,.....}
L2= Language of all words which contain substring "aa"
={aa,aaa,baa,aab,aaaa,baaa,aabb,bbaa,aaab,....}
L1 intersection L2={aa,aaa,baa,aaaa,baaa,.......}

L1-L2={a,ba,aba,bba,abba,.... }

1
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Differenceof two FA’s(𝑭𝑨𝟏 − 𝑭𝑨𝟐)


In finding the difference of two FA’s. We want a FA that accept words of𝐹𝐴1but not words
of 𝐹𝐴2. This procedure can be seen in three steps

1. Name the states of both FA’s


2. Make Transition table
3. Make FA for difference operation.

Example 1: Produce difference of given 𝐹𝐴′𝑠 (𝐹𝐴1 − 𝐹𝐴2).

𝑏 𝑎 𝑏 𝑎, 𝑏
𝑎 𝑎
−𝒙𝟏 +𝒙𝟐 −𝒚𝟏 𝒚𝟐 𝑎 +𝒚𝟑
𝑏 𝑏
𝑭𝑨𝟏 𝑭𝑨𝟐

Old States 𝒂 𝒃
−𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 } 𝒛𝟐 = {𝒙𝟐 , 𝒚𝟐 } 𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 }
+𝒛𝟐 = {𝒙𝟐 , 𝒚𝟐 } 𝒛 𝟑 = 𝒙 𝟐 , 𝒚𝟑 𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 }
𝒛𝟑 = {𝒙𝟐 , 𝒚𝟑 } 𝒛 𝟑 = 𝒙 𝟐 , 𝒚𝟑 𝒛𝟒 = {𝒙𝟏 , 𝒚𝟑 }
𝒛𝟒 = {𝒙𝟏 , 𝒚𝟑 } 𝒛 𝟑 = 𝒙 𝟐 , 𝒚𝟑 𝒛𝟒 = {𝒙𝟏 , 𝒚𝟑 }

𝑏 𝑎 𝑏
𝑎 𝑏
−𝒛𝟏 +𝒛𝟐 𝑎 𝒛𝟑 𝒛𝟒
𝑏 𝑎

2
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Example 2: Produce difference of given 𝐹𝐴′𝑠 in the order (𝐹𝐴2 − 𝐹𝐴1)

𝑏 𝑎 𝑏 𝑎, 𝑏
𝑎 𝑎
−𝒙𝟏 +𝒙𝟐 −𝒚𝟏 𝒚𝟐
𝑎 +𝒚𝟑
𝑏 𝑏
𝑭𝑨𝟏 𝑭𝑨𝟐

Old States 𝒂 𝒃
−𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 } 𝒛𝟐 = {𝒙𝟐 , 𝒚𝟐 } 𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 }
𝒛𝟐 = {𝒙𝟐 , 𝒚𝟐 } 𝒛 𝟑 = 𝒙 𝟐 , 𝒚𝟑 𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 }
𝒛𝟑 = {𝒙𝟐 , 𝒚𝟑 } 𝒛 𝟑 = 𝒙 𝟐 , 𝒚𝟑 𝒛𝟒 = {𝒙𝟏 , 𝒚𝟑 }
+𝒛𝟒 = {𝒙𝟏 , 𝒚𝟑 } 𝒛 𝟑 = 𝒙 𝟐 , 𝒚𝟑 𝒛𝟒 = {𝒙𝟏 , 𝒚𝟑 }

𝑏 𝑎 𝑏
𝑎 𝑏
−𝒛𝟏 𝒛𝟐 𝑎 𝒛𝟑 +𝒛𝟒
𝑏 𝑎

3
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Example 3: Provide difference of the both languages (𝐹𝐴1 − 𝐹𝐴2)

 language containing 00 as substring {00,100,001,000,1100,0011,0001,1001,....}


 language containing 11 as substring {11,110,011,111,0011,1100,1111,0110,....}

defined over set of alphabets Σ = {0,1}.


1 0,1 0 0,1
0 1

−𝒙𝟏 𝒙𝟐
0 +𝒙𝟑 −𝒚𝟏 𝒚𝟐
1 +𝒚𝟑
1 0
𝑭𝑨𝟏 𝑭𝑨𝟐
Old States 𝟎 𝟏
−𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 } 𝒛𝟐 = {𝒙𝟐 , 𝒚𝟏 } 𝒛𝟑 = {𝒙𝟏 , 𝒚𝟐 }
𝒛𝟐 = {𝒙𝟐 , 𝒚𝟏 } 𝒛𝟒 = {𝒙𝟑 , 𝒚𝟏 } 𝒛𝟑 = {𝒙𝟏 , 𝒚𝟐 }
𝒛𝟑 = {𝒙𝟏 , 𝒚𝟐 } 𝒛𝟐 = {𝒙𝟐 , 𝒚𝟏 } 𝒛𝟓 = {𝒙𝟏 , 𝒚𝟑 }
+𝒛𝟒 = {𝒙𝟑 , 𝒚𝟏 } 𝒛𝟒 = {𝒙𝟑 , 𝒚𝟏 } 𝒛𝟔 = {𝒙𝟑 , 𝒚𝟐 }
𝒛𝟓 = {𝒙𝟏 , 𝒚𝟑 } 𝒛𝟕 = {𝒙𝟐 , 𝒚𝟑 } 𝒛𝟓 = {𝒙𝟏 , 𝒚𝟑 }
+𝒛𝟔 = {𝒙𝟑 , 𝒚𝟐 } 𝒛𝟒 = {𝒙𝟑 , 𝒚𝟏 } 𝒛𝟖 = {𝒙𝟑 , 𝒚𝟑 }
𝒛𝟕 = {𝒙𝟐 , 𝒚𝟑 } 𝒛𝟖 = {𝒙𝟑 , 𝒚𝟑 } 𝒛𝟓 = {𝒙𝟏 , 𝒚𝟑 }
𝒛𝟖 = {𝒙𝟑 , 𝒚𝟑 } 𝒛𝟖 = {𝒙𝟑 , 𝒚𝟑 } 𝒛𝟖 = {𝒙𝟑 , 𝒚𝟑 }

−𝒛𝟏
1 𝒛𝟑
1 𝒛𝟓 1

0 1 1 0
0
𝒛𝟐 𝒛𝟕

0 0
1 1
0 +𝒛𝟒 +𝒛𝟔 𝒛𝟖 0,1
0

4
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Example 4: Provide difference of these two provided 𝐹𝐴′𝑠.(𝐹𝐴1 − 𝐹𝐴2)

 language Start with 𝑎𝑏.


 language end on 𝑏𝑎.

defined over set of alphabets Σ = {𝑎, 𝑏}.


𝑎, 𝑏 𝑎 𝑏

−𝒙𝟏
𝑎 𝒙𝟐 𝑏 +𝒙𝟑 −𝒚𝟏 𝑏 𝒚𝟐 𝑎 +𝒚𝟑

𝑏 𝑎 𝑏
𝑎
𝒙𝟒
𝑭𝑨𝟏 𝑭𝑨𝟐
𝑎, 𝑏
Old States 𝒂 𝒃
−𝒛𝟏 = {𝒙𝟏 , 𝒚𝟏 } 𝒛𝟐 = {𝒙𝟐 , 𝒚𝟏 } 𝒛𝟑 = {𝒙𝟒 , 𝒚𝟐 }
𝒛𝟐 = {𝒙𝟐 , 𝒚𝟏 } 𝒛𝟒 = {𝒙𝟒 , 𝒚𝟏 } 𝒛𝟓 = {𝒙𝟑 , 𝒚𝟐 }
𝒛𝟑 = {𝒙𝟒 , 𝒚𝟐 } 𝒛𝟔 = {𝒙𝟒 , 𝒚𝟑 } 𝒛𝟑 = {𝒙𝟒 , 𝒚𝟐 }
𝒛𝟒 = {𝒙𝟒 , 𝒚𝟏 } 𝒛𝟒 = {𝒙𝟒 , 𝒚𝟏 } 𝒛𝟑 = {𝒙𝟒 , 𝒚𝟐 }
+𝒛𝟓 = {𝒙𝟑 , 𝒚𝟐 } 𝒛𝟕 = {𝒙𝟑 , 𝒚𝟑 } 𝒛𝟓 = {𝒙𝟑 , 𝒚𝟐 }
𝒛𝟔 = {𝒙𝟒 , 𝒚𝟑 } 𝒛𝟒 = {𝒙𝟒 , 𝒚𝟏 } 𝒛𝟑 = {𝒙𝟒 , 𝒚𝟐 }
𝑧7 = {𝑥3 , 𝑦3 } 𝒛𝟖 = {𝒙𝟑 , 𝒚𝟏 } 𝒛𝟓 = {𝒙𝟑 , 𝒚𝟐 }
+𝑧8 = {𝑥3 , 𝑦1 } 𝒛𝟖 = {𝒙𝟑 , 𝒚𝟏 } 𝒛𝟓 = {𝒙𝟑 , 𝒚𝟐 }

𝑎 𝑏

−𝒛𝟏 𝑎 𝒛𝟐 𝑎 𝒛𝟒 +𝒛𝟓
𝑎 𝒛𝟕
𝑏
𝑏 𝑎 𝑎
𝑏 𝑏
𝒛𝟑
𝑏 𝒛𝟔 +𝒛𝟖
𝑎
𝑏
𝑎
L1={ab,aba,abb,abaa,abbb,abab,abba,......}
L2={ba,aba,bba,baba,abba,aaba,bbba,.....}

5
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Complementof FA’s
The complement of an 𝐹𝐴 accept words not in 𝐹𝐴. For this purpose, take complement of
each state w.r.t its final status. If the state is final, then make it as non-final state, andif the
state is non-final, then make it as final state.
Example 5: Provide complement of the given 𝐹𝐴.

 language havingEven number of 𝑎′𝑠 and Even number of 𝑏′𝑠defined over set of
alphabets Σ = {𝑎, 𝑏}.
𝑎
∓𝒙𝟏 𝒙𝟐
𝑎

𝑏 𝑏 𝑏 𝑏

𝑎
𝒙𝟑 𝒙𝟒
𝑎
Solution:The complement of an 𝐹𝐴 accept words not in 𝐹𝐴. So, the complement of the given
𝐹𝐴 as shown below.

𝑎
−𝒚𝟏 +𝒚𝟐
𝑎

𝑏 𝑏 𝑏 𝑏

𝑎
+𝒚𝟑 +𝒚𝟒
𝑎

6
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Example 6: Provide complement of the given 𝐹𝐴 that acceptlanguage start with 𝑎𝑏defined
over set of alphabets Σ = {𝑎, 𝑏}.

𝑎, 𝑏

−𝒙𝟏
𝑎 𝒙𝟐 𝑏 +𝒙𝟑

𝑏 𝑎
𝒙𝟒

𝑎, 𝑏

Solution: Complement of the given 𝐹𝐴 will be

𝑎, 𝑏

∓𝒙𝟏 𝑎 +𝒙𝟐 𝑏 𝒙𝟑

𝑏 𝑎
+𝒙𝟒

𝑎, 𝑏

7
Dr. Muhammad Zeeshan Muzaffar email id: Zeeshan@biit.edu.pkWhatsapp# 0331-5824043
Dr. Naseer Ahmad Sajid email id: Naseer@biit.edu.pkWhatsapp# 0346-5100010

Assignment No. 8
FA’s are given for the questions
FA1: The languagestarts with‘𝒂𝒃’ defined over ∑={𝒂, 𝒃}.
𝑎, 𝑏

−𝒙𝟏 𝑎 𝒙𝟐 𝑏 +𝒙𝟑

𝑏 𝑎
𝒙𝟒

𝑎, 𝑏
FA2: The language containsubstring ‘𝒂𝒃’ or ‘𝒃𝒂’ defined over ∑={𝒂, 𝒃}.
𝑎

𝒙𝟐 𝑎, 𝑏
𝑎 𝑏
−𝒙𝟏 +𝒙𝟒

𝑏 𝒙𝟑 𝑎

𝑏
FA3: Language of all words having even number of 𝑎′𝑠 and even number of
𝑎
∓𝒚𝟏 𝒚𝟐
𝑎

𝑏 𝑏 𝑏 𝑏

𝑎
𝒚𝟑 𝒚𝟒
𝑎
𝑏′𝑠.

Question 1: Find the 𝐹𝐴equivalent to 𝐹𝐴1 − 𝐹𝐴2 ?


Question 2: Find the 𝐹𝐴 equivalent to 𝐹𝐴2 − 𝐹𝐴3 ?
Question 3: Find the complement of Question 1?
Question 4: Find the complement of Question 2?
8

You might also like