0% found this document useful (0 votes)
34 views

Week 2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Week 2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

THE0RY OF AUTOMATA & LANGUAGES

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Theory of Automata -Languages

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
Week-02
• Alphabets and strings, Languages, Defining Languages.
• Intro to defining languages , Kleene Star Closure and +
operator, Palindrome Langauge

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


More About Automata
Automata theory : the study of abstract computing devices, or ”machines”
Before computers (1930), A. Turing studied an abstract machine (Turing machine) that had all
the capabilities of today’ s computers (concerning what they could compute). His goal was to
describe precisely the boundary between what a computing machine could do and what it could
not do.
Simpler kinds of machines (finite automata) were studied by a number of researchers and
useful for a variety of purposes
Theoretical developments bear directly on what computer scientists do today.
Finite automata, formal grammars: design/ construction of software

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


CENTRAL CONCEPT OF AUTOMATA
THEORY

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
ALPHABET
A finite, nonempty set of symbols.
Symbol: Σ
Example:

1. The binary alphabet: Σ = {0, 1}


2. The set of all lower-case letters: Σ = {a, b, . . . , z}.
3.The set of all ASCII character.

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


STRING
A string (or sometimes a word) is a finite sequence of symbols chosen from some alphabet
Example: 01101 and 111 are strings from the binary alphabet Σ = {0, 1}.
Empty string: the string with zero occurrences of symbols.
Length of a string: the number of positions for symbols in the string.
Example 01101 has length 5.
There are only two symbols (0 and 1) in the string 01101, but 5 positions forSymbols.
Notation of length of w: |w|
Example: |011| = 3

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Power Of Alphabet
If Σ is an alphabet, we can express the set of all strings of a certain length from that
alphabet by using the exponential notation:
Example: Σ0 : {ǫ}, regardless of what alphabet Σ is. That is ǫ is the only string of length
0
If Σ = {0, 1}, then
1. Σ1 = {0, 1}
2. Σ2 = {00, 01, 10, 11}
3.Σ3 = {000, 001, 010, 011, 100, 101, 110, 111
Note: confusion between Σ and Σ1:
Σ is an alphabet; its members 0 and 1 are symbols
Σ1 is a set of strings; its members are strings (each one of length 1)
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
KLEEN STAR */Closure/Operator
Kleen PLUS+/Positive/Positive Closure
Lexicographic Order

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


KLEEN STAR *
Σ∗: The set of all strings over an alphabet Σ
EXAMPLE
1.{0, 1}∗ = {ǫ, 0, 1, 00, 01, 10, 11, 000, . . .}
2.Σ∗ = Σ0 ∪ Σ1 ∪ Σ2 ∪ . . .

The symbol ∗ is called Kleene star and is named after the mathematician and
logician Stephen Cole Kleene.
Σ+ = Σ1 ∪ Σ2 ∪ . . .
Thus: Σ∗ = Σ+ ∪ {ǫ}

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Kleene Closure / Plus

 Definition − The set ∑+ is the infinite set of all possible strings of all possible lengths over ∑
excluding λ.
 Representation − ∑+ = ∑1 ∪ ∑2 ∪ ∑3 ∪…….
 ∑+ = ∑* − { λ }
 Example − If ∑ = { a, b } , ∑+ = { a, b, aa, ab, ba, bb,………..}

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
LANGUAGES
If Σ is an alphabet, and L ⊆ Σ∗, then L is a (formal) language over Σ.
Language: A (possibly infinite) set of strings all of which are chosen from some Σ∗
A language over Σ need not include strings with all symbols of Σ, Thus, a language over Σ is also a
language over any alphabet that is a superset of Σ
1.Programming language C
2.English or French

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


LANGUAGES

 Definition − A language is a subset of ∑* for some alphabet ∑. It can be finite or infinite.


 Example − If the language takes all possible strings of length 2 over ∑ = {a, b}, then L = {
ab, aa, ba, bb }

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


CONCATENATION
Thus, strings can be concatenated yielding another string:
If x are y be strings then x.y denotes the concatenation of x and y, that is, the string formed by
making a copy of x and following it by a copy of y
Examples:
1.x = 01101 and y = 110
2.Then xy = 01101110 and yx = 11001101

If S and T are subsets of Σ∗, then


S.T = {s.t | s ∈ S, t ∈ T }

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
• Descriptive definition of
language – Explained with
Examples
• Language Palindrome

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Descriptive definition of language – Explained
with Examples

In the Theory of automata, languages can be defined with different techniques. Some of these are
mentioned below;
Language definition by using the Descriptive definition
Language definition by using the Recursive definition
Language definition by using the Regular Expressions (RE)
Language definition by using the Finite Automaton(FA)

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Descriptive definition of language – Explained with Examples

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
Example 1 of Descriptive definition of language
Descriptive definition of the language of strings of odd length, defined over Σ={a},
can be defined as
L={a, aaa, aaaaa,…..}

Example 2 of Descriptive definition of language


Descriptive definition of the language of strings of even length, defined over Σ={a},
can be defined as
L={aa, aaaa, aaaaaa, aaaaaaaa…..}

Example 3 of Descriptive definition of language


Descriptive definition of the language of strings that must
start with a, defined over Σ ={a,b,c}, can be defined as L ={a,
ab, aa, aba, abb, ac, acc, ….}
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
Example 4 of Descriptive definition of language
Descriptive definition of the language of strings that does
not start with a, defined over Σ ={a,b,c}, can be defined as L
={Λ, b, c, ba, bb, bc, ca, cb, cc, …}

Example 5 of Descriptive definition of language


Descriptive definition of the language of the strings of length 1, defined over
Σ ={X,Y,Z}, can be defined as
L={X, Y, Z }

Example 6 of Descriptive definition of language


Descriptive definition of the language of the strings of length 2, defined over
Σ ={X,Y,Z}, can be defined as
L={XX, XY, XZ,YX, YY,YZ,ZX,ZY,ZZ, …..}
DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
Example 7
Descriptive definition of the language of the strings of length 3,
defined over Σ ={X,Y,Z}, can be defined as.

Example 8
Descriptive definition of the language L of strings ending in a, defined over Σ ={a,b}, can
be defined as
L={a,aa,ba,aaa,aba,baa,bba,…}

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Example

The language {anbn }, of strings defined over Σ={a,b}, as


{an bn : n=1,2,3,…}, can be written as
{ab, aabb, aaabbb,aaaabbbb,…}

Example

The language {anbnan }, of strings defined over Σ={a,b}, as


{an bn an: n=1,2,3,…}, can be written as
{aba, aabbaa, aaabbbaaa,aaaabbbbaaaa,…}

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


CLASS TASK

{Λ, aa, bb, aaaa,aabb,aabb, abba, baba, bbaa, ,…}

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Recursive Definition

 It is one of the Language defining methods.


 In this method, we simply describe the Language with three steps/rules

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


RULES FOR DEFINNING LANGUAGES.

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
CLASS TASK

Define Recursive definition of ODD POSITIVE NUMBERS

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY
Defining the language {𝑎^𝑛 𝑏^𝑛} n=1,2,3,… , of strings defined over Σ={a,b}

Step 1: ab is in {𝑎𝑛 𝑏 𝑛 }
Step 2: if x is in {𝑎𝑛 𝑏 𝑛 } then axb is in {𝑎𝑛 𝑏 𝑛 }
Step 3: No strings except those constructed in above, are allowed to be in {𝑎𝑛 𝑏 𝑛 }

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Defining the language L, of strings ending in a , defined over Σ={a,b}

Step 1: a is in L
Step 2: if x is in L then s(x) is also in L, where s belongs to Σ*
Step 3: No strings except those constructed in above, are allowed to be in L

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Defining the language L, of strings beginning and ending in same
letters , defined over Σ={a, b}

Step 1: a and b are in L


Step 2: (a)s(a) and (b)s(b) are also in L, where s belongs to Σ*
Step 3: No strings except those constructed in above, are allowed to be in L

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Defining the language L, of strings containing aa or bb , defined over Σ={a, b}

Step 1: aa and bb are in L


Step 2: s(aa)s and s(bb)s are also in L, where s belongs to Σ*
Step 3: No strings except those constructed in above, are allowed to be in L

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


TEXT BOOK

https://pakistandasti.files.wordpress.com/2013/11/introductio
n-to-computer-theory-by-cohen-copy.pdf

Chapter 2 & 3

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


Thank You

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY


THE END

DEPARTMENT OF COMPUTING, FCIT, INDUS UNIVERSITY

You might also like