You are on page 1of 25

HEWAD UNIVERSITY

‫هیــــواد پوهنــتون‬
Theory of Computation

Lecturer : Mirajuddin Haidari

Department
HEWAD University of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

INTRODUCATION
• Course Name: TOC
• Lecturer Name: Mirajuddin Haidari
• Email: Mearajuddin.haidary@gmail.com
• WhatsApp: +93747007958

2
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

CONTENTS OF THE LECTURE


1. Descriptive Language definition

3
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• The language DOUBLEFACTORIAL, of strings
defined over Σ={a, b}, as
• {an!bn! : n=1,2,3,…}, can be written as
•{ab, aabb, aaaaaabbbbbb,…}

4
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• The language SQUARE, of strings defined over
Σ={a}, as
•{an2: n=1,2,3,…}, can be written as
•{a, aaaa, aaaaaaaaa,…}

5
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• The language DOUBLESQUARE, of strings
defined over Σ={a,b}, as
2 n2
•{a b : n=1,2,3,…}, can be written as
n

•{ab, aaaabbbb, aaaaaaaaabbbbbbbbb,…}

6
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• The language PRIME, of strings defined over
Σ={a}, as
•{ap : p is prime}, can be written as
•{aa,aaa,aaaaa,aaaaaaa,aaaaaaaaaaa…}

7
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

PALINDROME
• The language consisting of Λ and the strings s
defined over Σ such that Rev(s)=s
• Example
– Σ={a,b}
– PALINDROME={Λ , a, b, aa, bb, aaa, aba, bab, bbb, ...}
• Palindrome(A word or phrase that reads the same backward as forward)

8
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Kleene Star Closure


• Given Σ, then the Kleene Star Closure of the
alphabet Σ, is the collection of all strings defined
over Σ, including Λ

• Denoted by Σ*

9
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Examples
• If Σ = {x}
– Then Σ* = {Λ, x, xx, xxx, xxxx, ….}
• If Σ = {0,1}
– Then Σ* = {Λ, 0, 1, 00, 01, 10, 11, ….}
• If Σ = {aaB, c}
– Then Σ* = {Λ, aaB, c, aaBaaB, aaBc, caaB, cc, ….}

10
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Note
• Languages generated by Kleene Star Closure
of set of strings, are infinite languages
• – i.e. the language contains infinite many words,
each of finite length

11
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

PLUS Operation (+)


• Plus Operation is same as Kleene Star Closure except that
it does not generate Λ (null string), automatically
• Example:
– If Σ = {0,1}
• Then Σ+ = {0, 1, 00, 01, 10, 11, ….}
– If Σ = {aab, c}
• Then Σ+ = {aab, c, aabaab, aabc, caab, cc, ….}

12
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Question???
• Is this possible for Λ to be part of a language
generated by Σ+ ??
• Yes …… pur kaisay
• Example?
– Σ = {Λ,a}
– Then Σ+ = {Λ, a, aa, aaa, aaaa, ….}

13
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Remark
• Kleene Star can also be operated on any string
• Example:
• a* generates {Λ, a, aa, aaa, …}
• a+ can be considered to be all possible non empty strings
• Example:
• a+ generates
• {a, aa, aaa, aaaa, …}
• 2*?
• 3+?

14
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Powers of an Alphabet
• Σk = the set of strings of length k with symbols
from Σ
• Example – Σ={0,1}
– Σ1= {0,1}
– Σ2= {00; 01; 10; 11}
– Σ0= {ε}

15
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Continue…
• The set of all strings over Σ is denoted byΣ*
• Σ*= Σ0UΣ1UΣ2UΣ3 U……..
• Σ+= Σ1UΣ2UΣ3 U……..
• Σ*= Σ+U {ε}

16
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• Construct a DFA over ∑Ꜫ{a,b} which accept the string with
length of >= 2.

17
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• Construct a DAF over ∑Ꜫ{a,b} which accept the string with
length of <= 2.

18
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• Construct a minimal DAF over ∑Ꜫ{a,b} which accept the
string with |∑| mode 2 = 0.

19
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Example
• Construct a minimal DAF over ∑Ꜫ{a,b} which accept the string
with |∑| mode 2 != 0.

20
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Class Activity
1. Construct a DFA w = {a,b}* which string are dividable for
3?

2. Construct a Minimal DFA over w = {a,b}* where number of


a in string is 2 {na(w) = 2}?

3. Construct a DAF which string are not dividable for 3?

21
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Assignment
1. Construct a Minimal DFA over w = {a,b}* where number of
a in string is grater or equal to 2 {na(w) => 2}?

2. Construct a Minimal DFA over w = {a,b}* where number of


a in string is grater than 2 {na(w) > 2}?

22
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Formal Language
• L(G) is the notation for a language defined by a grammar G.
The grammar G recognizes a certain set of strings, thus a
language.
• M(L) is the notation for a machine that accepts a language.
The language L is a certain set of strings.
• G(L) is the notation for a grammar that recognizes a
language.
• The language L is a certain set of strings.

23
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Union, intersection, complement, difference


• The union of two languages is a language.
• L = L1 union L2
• The intersection of two languages is a language.
• L = L1 intersect L2
• The complement of a language is a language.
• L = sigma* - L1
• The difference of two languages is a language.
• L = L1 - L2

24
HEWAD University
Department
of Computing & Technology ‫کمپیوتر ساینس پوهنځی‬ ‫هیــــواد پوهنــتون‬

Let’s Stop
it Here
25

You might also like