0% found this document useful (0 votes)
41 views22 pages

TCS Lect 2 - 3 Basic Concepts

TCS Lect 2 - 3 Basic Concepts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views22 pages

TCS Lect 2 - 3 Basic Concepts

TCS Lect 2 - 3 Basic Concepts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

BASIC CONCEPTS AND

FINITE AUTOMATA
MODULE 1

Prepared By: Mr. Vaibhav


CONTENT

• ALPHABET, STRINGS
• OPERATIONS ON STRINGS
• LANGUAGES
• OPERATIONS ON LANGUAGES
• EXAMPLE

Prepared By: Mr. Vaibhav


Basic concepts of language

• Alphabet: Non empty set Σ of symbol or finite collection of symbols

• Strings: Finite sequence of symbols from alphabet

E.g. If Alphabet Σ = { a, b }

Then possible set of strings S = { a, b, abb, ba,


bbbb }

Prepared By: Mr. Vaibhav


Basic concepts of language

Certain Notations:

1. Lower case letters are used to represent strings

2. a, b, c, … are used for elements of Σ

3. u, v, w, … are used for string names

E. g. w = abaa

The meaning of above expression is 'w' is string name


which has specified value 'abaa'
Prepared By: Mr. Vaibhav
More on Strings …...

Concatenation of Strings: Appending the symbol of second string at


the end of the first string

E. g. If w = a1a2 … an

v = b1b2 … bm

Then v . w = b1b2 … bm a1a2 … an

w . v = a1a2 … an b1b2 … bm
Prepared By: Mr. Vaibhav
More on Strings …...

• Reverse of a string: Writing symbols of the string in reverse order

E. g. If w = a 1a2 … a n

Then w R = a n … a 2a1

• Length of string: Number of symbols in the string denoted by | w | for


string w

E. g. If w = aab

Then |w| = 3
Prepared By: Mr. Vaibhav
More on Strings …...
• Empty string: String with no symbols. It is denoted by epsilon ε

|ε|=0

ε.w = w.ε = w

• Substring: Any string with consecutive symbols in w is said to be substring of w.

If w=u. v

Then u -> Prefix v -> Suffix

Here | uv | = |u| + |v|

E.g. If w = abbab

Set of All Prefixes P = { ε, a, ab, abb, abba, abbab }

Set of All Suffixes. S = { ε, b, ab, bab, bbab, Prepared


abbab } By: Mr. Vaibhav
More on Strings …...
• If w is a string then

wn stands for string obtained by repeating 'w' n times

• Special Case: w0 = ε For all w

• If Σ is an alphabet then we use Σ* to denote the set of strings obtained by


concatenating zero or more symbols from Σ

• Σ* includes all the strings and ε

• To exclude empty string we define Σ+ = Σ* - {ε}

• Σ is finite set of symbols but Σ+ and Σ* are infinite set of strings as there is no
limit to length of the string in set
Prepared By: Mr. Vaibhav
Language

• Language is collection of appropriate strings. It is generally subset


of Σ*

• Sentence: A string in a language L will be called as sentence of L

• Ex. 1 Let Σ = { a, b }

Σ* = { ε, a, b, aa, ab, ba, bb, aaa, … }

If L = { a, aa, aab } then L is a language on Σ

Here L is a finite language where number of sentences


are countable
Prepared By: Mr. Vaibhav
Language

• Ex. 2 Let Σ = { a, b }

and if L = { a n bn | n ≥ 0 }

then Σ* = { ε, a, b, aa, ab, ba, bb, aaa, … }

L = { ε, ab, aabb, aaabbb, … }

L is a language on Σ

Here L is an infinite language


Prepared By: Mr. Vaibhav
Operations on Languages
If L1 and L2 are two languages then

1. Union: L1 U L2

2. Intersection: L1 ∩ L2

3. Difference of Languages: L1 - L2

4. Concatenation of Languages: L1 .
L2

L1 . L2 = { x . y | x ∈ L1 and y ∈ L2 }

Special case: Ln - L concatenated with itself 'n' times

Prepared By: Mr. Vaibhav


Operations on Languages

5. Complement of a Language ( L ): It is defined with respect to Σ*

L = Σ* - L

6. Reverse of a language ( LR): It is set of all strings in reverse


format

LR = { wR | w ε L }

Prepared By: Mr. Vaibhav


Operations on Languages

7. Star Closure of a language ( L*)

L* = L0 U L 1 U L2 …

8. Positive Closure of a language ( L+ )

L+ = L1 U L2 U L3 ...

Prepared By: Mr. Vaibhav


Examples
Describe the language over the input set A = {a,b}

Ex. 1 L1 = { a, ab, ab2, ab3, ab4 , … }

Ex. 2 L2 = { anbn | n ≥ 1 }

L2 = { ab, a2b2, a3b3, …}

Ex. 3 L3 = { ambn | n > 0 }

L3 = { b, ab, a2b, ab2, … }


Prepared By: Mr. Vaibhav
OPERATIONS ON LANGUAGES
• L1 U L2 = { a, ab, ab2, a2b2, ab3, a3b3, … }
• L1 ∩ L2 = { ab }
• L1 – L2 = { a, ab2, ab3, ab4, … }
• L1 . L2 = { aab, aa2b2, aa3b3, abab, aba2b2, … }
= { aab, a3b2, a4b3, abab, aba2b2, … }
• L1R = { a, ba, b2a, b3a, b4a, … }
• L2R = { ba, b2a2, b3a3, … }

Prepared By: Mr. Vaibhav


FINITE AUTOMATA
• A finite automata is a collection of five tuples ( Q, Σ, delta ( δ ) , q0 , F
)
Where Q is a finite set of states
Σ is input alphabet
q0 is an initial state q0 ∈ Q

F is a set of final states


(delta) δ is a Transition Function or Mapping Function
• The strings and languages can be accepted by a finite automata
when it reaches to the final state
Prepared By: Mr. Vaibhav
Representation of Finite Automata
1. Transition Diagram

1
S1
0
S2

S0
S0 – Start State
0 S2 – Final State
1 0 S3 S1, S3, S4 – Other
S4
States

Prepared By: Mr. Vaibhav


Representation of Finite Automata

• Example for transition diagram to accept the string 'aabb'

a a b b
S0 S1 S2 S3 S4

Start State: S0

Final State: S4
Other States: S1, S2,
Prepared By: Mr. Vaibhav
Representation of Finite Automata
2. Transition table
Tabular representation of finite automata
Rows – states
Columns – inputs State/ a b
Input
Transition S0 S1 --
S1 S2 --
1. δ ( S0 , a ) = S1
S2 -- S3
2. δ ( S1, a ) = S2 S3 -- S4
S4 --
3. δ ( S2, b ) = S3
4. δ ( S3, b ) = S4
Prepared By: Mr. Vaibhav
Finite State Machine

It is represented using
a b a b a b

1. Input Tape: Linear tape having


number of cells. Each cell has one Tape
Reader
input symbol

2. Tape Reader: It reads input Finite Control


symbols from left to right. One
symbol is read at a time

3. Finite Control: It decides the next Prepared By: Mr. Vaibhav


Finite State Machine

If current state is S0 and input symbol


a b a b a b
read is 'a' then finite control will decide
the next state. Tape
Reader

The transition from S0 with input 'a' to Finite Control


next state S1 producing 'v' can be
represented as

( S0 , a ) |- ( S1 , v ) Prepared By: Mr. Vaibhav


Finite State Machine
• If w is a string then w is accepted by
Finite Automata a b a b a b

( w , s ) |* (q,€)
Tape
Reader
with q is final state

• The set of strings accepted by Finite


Finite Control
Automata given by M, then M is
accepted by language L

• It is denoted by L(M)
Prepared By: Mr. Vaibhav

You might also like