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

Unit-1 Toc

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

Unit-1 Toc

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

CS3452-THEORY OF COMPUTATION

ONLINE CLASS

PRESENTED BY
Mr. K. SANKAR GANESH
AP/CSE
OBJECTIVES:

• To understand foundations of computation including


automata theory
• To construct models of regular expressions and languages.
• To design context free grammar and push down automata
• To understand Turing machines and their capability
• To understand Undecidability and NP class problems

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
UNIT I
AUTOMATA AND REGULAR EXPRESSIONS

• Proofs
• Deterministic Finite Automata
• Non-deterministic Finite Automata
• Finite Automata with Epsilon Transitions
• Equivalence of NFA-DFA- e-NFA

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
UNIT II
REGULAR EXPRESSIONS AND
LANGUAGES

• Regular Expressions
• FA and Regular Expressions
• Proving Languages not to be regular
• Equivalence and Minimization of
Automata
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
UNIT III
CONTEXT FREE GRAMMAR AND PUSH
DOWN AUTOMATA
• CFG
• Derivation
• Parse Trees
• Ambiguity
• Pushdown
Defn. language acceptance, moves
design of PDA
Equivalence of PDA and CFG
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
UNIT IV
NORMAL FORMS AND TURING MACHINES

• Normal Forms for CFG


• Pumping Lemma for CFL
• Turing Machines
Defn. Language Acceptance, moves,
Design of TM

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
UNIT V
UNDECIDABILITY

• Non Recursive Enumerable (RE)


Language
• Undecidable Problem with RE
• Undecidable Problems about TM

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
OUTCOMES:
Upon completion of the course, the students will
be able to:

CO1: Construct automata theory using Finite Automata


CO2: Write regular expressions for any pattern
CO3: Design context free grammar and Pushdown
Automata
CO4: Design Turing machine for computational functions
CO5: Differentiate between decidable and undecidable
problems
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
TEXT BOOK:
1. J.E.Hopcroft, R.Motwani and J.D Ullman,
Introduction to Automata Theory, Languages and
Computations
Third Edition, Pearson Education, 2008.
2. John C Martin ,
"Introduction to Languages and the Theory of
Computation",
4th Edition, Tata McGraw Hill, 2011.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC,
VELLORE
REFERENCES:
1. Harry R Lewis and Christos H Papadimitriou ,
"Elements of the Theory of Computation", 2nd
Edition, Prentice Hall of India, 2015.
2. Peter Linz, "An Introduction to Formal
Language and Automata", 6th Edition, Jones &
Bartlett, 2016.
3. K.L.P.Mishra and N.Chandrasekaran, “Theory of
Computer Science: Automata Languages and
Computation”, 3rd Edition, Prentice Hall of
India, 2006.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Automata – What is it?

The term "Automata" is derived from the Greek


word "αὐτόματα" which means "self-acting".

An automaton (Automata in plural) is an abstract


self-propelled computing device which follows a
predetermined sequence of operations
automatically.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Can you read this?

• COMPUTER

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Can you read this?

• கணினி

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Can you read this?

• కంప్యూటర్

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Can you read this?

• കമ്പ്യൂട്ടർ

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Can you read this?

‫الحاسوب‬

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
TYPES OF GRAMMAR

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
FINITE AUTOMATA
•Finite automata are used to recognize
patterns.
•It takes the string of symbol as input and
changes its state accordingly. When the
desired symbol is found, then the transition
occurs.
•At the time of transition, the automata can
either move to the next state or stay in the
same state.
•Finite automata have two states, Accept
state or Reject state. When the input
string is processed successfully, and the
automata reached its final state, then it will
accept.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
•Pushdown automata is a way to implement a CFG
FA can remember a finite amount of information, but
PUSHDOWN ATOMATA
a PDA can remember an infinite amount of
information.

•Pushdown automata is simply an NFA augmented


with an "external stack memory".

•A PDA is more powerful than FA.

•Any language which can be acceptable by FA can


also be acceptable by PDA.

•PDA also accepts a class of language which even


cannot be accepted by FA. Thus PDA is much more
superior to FA.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
TURING MACHINE

Turing machine was invented in 1936 by Alan


Turing.
It is an accepting device which accepts Recursive
Enumerable Language generated by type 0
grammar.

There are various features of the Turing machine:


1.It has an external memory which remembers
arbitrary long sequence of input.

2.It has unlimited memory capability.

3.The model has a facility by which the input at left


or right on the tape can be read easily.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
FA TM

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
BASIC TERMINOLOGY

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
INTRODUCTION
Symbols:
Symbols are an entity or individual objects, which can be any letter, character or any picture.

Example:
1, a, b, #

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Kleen Closure/Star

Positive Closure

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
FINITE AUTOMATA
•Finite automata are used to recognize
patterns.
•It takes the string of symbol as input and
changes its state accordingly. When the
desired symbol is found, then the transition
occurs.
•At the time of transition, the automata can
either move to the next state or stay in the
same state.
•Finite automata have two states, Accept
state or Reject state. When the input string is
processed successfully, and the automata
reached its final state, then it will accept.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Formal Definition of FA

A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F),

where:
1.Q: finite set of states
2.∑: finite set of the input symbol
3.q0: initial state
4.F: final state
5.δ: Transition function

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
A transition diagram or state transition diagram is a
directed graph which can be constructed as follows:

•There is a node for each state in Q, which is represented


by the circle.

•There is a directed edge from node q to node p labeled a


if δ(q, a) = p.

•In the start state, there is an arrow with no source.

•Accepting states or final states are indicating by a double


circle.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Transition Table
The transition table is basically a tabular representation of
the transition function.

It takes two arguments (a state and a symbol) and returns a


state (the "next state").

A transition table is represented by the following things:


•Columns correspond to input symbols.
•Rows correspond to states.
•Entries correspond to the next state.
•The start state is denoted by an arrow with no source.
•The accept state is denoted by a star/ cirle.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Finite Automaton can be classified into two types

•Deterministic Finite Automaton (DFA)


•Non-deterministic Finite Automaton (NDFA / NFA)

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
1. DFA
• DFA refers to deterministic finite automata.
• Deterministic refers to the uniqueness of the computation.
• In the DFA, the machine goes to one state only for a particular
input character. DFA does not accept the null move.
2. NFA
• NFA stands for non-deterministic finite automata.
• It is used to transmit any number of states for a particular input.
• It can also accept the null move.

NFA with ∈ move: If any FA contains ε transition or move, the finite


automata is called NFA with ∈.
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Formal Definition of a DFA

A DFA can be represented by a 5-tuple (Q, ∑, δ, q0, F)


where −

•Q is a finite set of states.


•∑ is a finite set of symbols called the alphabet.
•δ is the transition function where δ: Q × ∑ → Q
•q0 is the initial state from where any input is
processed (q0 ∈ Q).
•F is a set of final state/states of Q (F ⊆ Q).
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Formal Definition of an NDFA
An NDFA can be represented by a 5-tuple (Q, ∑, δ, q0, F)
where −
•Q is a finite set of states.
•∑ is a finite set of symbols called the alphabets.
•δ is the transition function where δ: Q × ∑ → 2 Q
•(Here the power set of Q (2Q) has been taken because in
case of NDFA, from a state, transition can occur to any
combination of Q states)
•q0 is the initial state from where any input is processed
(q0 ∈ Q).
•F is a set of final state/states of Q (F ⊆ Q).
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
1. DFA ?
2. NFA ?

1. DFA ?
2. NFA ?

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
1.DFA

2. NFA

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Some important points about DFA and NFA:

1.Every DFA is NFA, but NFA is not DFA.

2.There can be multiple final states in both NFA and DFA.

3.DFA is used in Lexical Analysis in Compiler.

4.NFA is more of a theoretical concept.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
NFA

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
NFA WITH ε TO NFA WITHOUT ε
NFA with ε can be converted to NFA without ε, and this NFA without ε can be converted to DFA.

To do this, we will use a method, which can remove all the ε transition from
given NFA.
The method will be:

STEP 1: Find out all the ε transitions from each state from Q.
That will be called as ε-closure{qi} where qi ∈ Q.

STEP 2: Then δ' transitions can be obtained.


The δ' transitions mean a ε-closure on δ moves.

STEP 3: Repeat Step-2 for each input symbol and each state of given NFA.

Using the resultant states, the transition table for equivalent NFA without ε can
be built. Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
ε-closure: ε-closure for a given state A means a set of states
which can be reached from the state A with only ε(null) move
including the state A itself.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
1.ε-closure {q0} = {q0, q1, q2}
2.ε-closure {q1} = {q1}
3.ε-closure {q2} = {q2}
4.ε-closure {q3} = {q3}
5.ε-closure {q4} = {q4}

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
1.ε-closure {q0} = {q0, q1}
2.ε-closure {q1} = {q1}

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
δ'(q0, x) = ε-closure(δ(δ^(q0, ε),x))

δ^(q0, ε) = ε- closure(q0)

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
We will first obtain ε-closures of
q0, q1 and q2 as follows:

1.ε-closure(q0) = {q0}
2.ε-closure(q1) = {q1, q2}
3.ε-closure(q2) = {q2}

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Now the δ' transition on each input symbol is obtained as:

δ'(q0, a) = ε-closure(δ(δ^(q0, ε),a))


= ε-closure(δ(ε-closure(q0),a))
= ε-closure(δ(q0, a))
= ε-closure(q1)
= {q1, q2}
δ'(q0, a) = {q1, q2} …………1

δ'(q0, b) = ε-closure(δ(δ^(q0, ε),b))


= ε-closure(δ(ε-closure(q0),b))
= ε-closure(δ(q0, b))

δ'(q0, b) = Ф ………….2
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Now the δ' transition on q1 is obtained as:
δ'(q1, a) = ε-closure(δ(δ^(q1, ε),a))
= ε-closure(δ(ε-closure(q1),a))
= ε-closure(δ(q1, q2), a)
= ε-closure(δ(q1, a) ∪ δ(q2, a))
= ε-closure(Ф ∪ Ф)

δ'(q1, a) = Ф………..3

δ'(q1, b) = ε-closure(δ(δ^(q1, ε),b))


= ε-closure(δ(ε-closure(q1),b))
= ε-closure(δ(q1, q2), b)
= ε-closure(δ(q1, b) ∪ δ(q2, b))
= ε-closure(Ф ∪ q2)
= {q2}
δ'(q1, b) = {q2} …………4
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
The δ' transition on q2 is obtained as:

δ'(q2, a) = ε-closure(δ(δ^(q2, ε),a))


= ε-closure(δ(ε-closure(q2),a))
= ε-closure(δ(q2, a))
= ε-closure(Ф)

δ'(q2, a) = Ф …………..5

δ'(q2, b) = ε-closure(δ(δ^(q2, ε),b))


= ε-closure(δ(ε-closure(q2),b))
= ε-closure(δ(q2, b))
= ε-closure(q2)
= {q2}
δ'(q2, b) = {q2} ---------------- 6
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
summarize all the computed δ' transitions:

1.δ'(q0, a) = {q0, q1}


2.δ'(q0, b) = Ф
3.δ'(q1, a) = Ф
4.δ'(q1, b) = {q2}
5.δ'(q2, a) = Ф
6.δ'(q2, b) = {q2} State q1 and q2 become the final state
as ε-closure of q1 and q2 contain the final state q2.

The transition table can be:

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
NFA WITH ε NFA WITHOUT ε

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
converting NFA with ε to DFA:

Step 1: We will take the ε-closure for the starting state of NFA as a
starting state of DFA.
Step 2: Find the states for each input symbol that can be traversed
from the present. That means the union of transition value and their
closures for each state of NFA present in the current state of DFA.
Step 3: If we found a new state, take it as current state and repeat
step 2.
Step 4: Repeat Step 2 and Step 3 until there is no new state present
in the transition table of DFA.
Step 5: Mark the states of DFA as a final state which contains the
final state of NFA. Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Example 1:

1.ε-closure {q0} = {q0, q1, q2}


2.ε-closure {q1} = {q1}
3.ε-closure {q2} = {q2}
4.ε-closure {q3} = {q3}
5.ε-closure {q4} = {q4}

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Now, let ε-closure {q0} = {q0, q1, q2} be state A.

δ'(A, 0) = ε-closure {δ((q0, q1, q2), 0) }


= ε-closure {δ(q0, 0) ∪ δ(q1, 0) ∪ δ(q2, 0) }
= ε-closure {q3}
= {q3} call it as state B.

δ'(A, 1) = ε-closure {δ((q0, q1, q2), 1) }


= ε-closure {δ((q0, 1) ∪ δ(q1, 1) ∪ δ(q2, 1) }
= ε-closure {q3}
= {q3} = B.

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
δ'(B, 0) = ε-closure {δ(q3, 0) }
= ϕ
δ'(B, 1) = ε-closure {δ(q3, 1) }
= ε-closure {q4}
= {q4} i.e. state C

δ'(C, 0) = ε-closure {δ(q4, 0) }


= ϕ
δ'(C, 1) = ε-closure {δ(q4, 1) }
= ϕ

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Example 2:

1.ε-closure(q0) = {q0, q1, q2}


2.ε-closure(q1) = {q1, q2}
3.ε-closure(q2) = {q2}

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
NDFA to DFA Conversion
Let X = (Qx, ∑, δx, q0, Fx) be an NDFA which accepts the language L(X). We have to design an
equivalent DFA Y = (Qy, ∑, δy, q0, Fy) such that L(Y) = L(X). The following procedure converts the
NDFA to its equivalent DFA −

Suppose there is an NFA N < Q, ∑, q0, δ, F > which recognizes a language L.


Then the DFA D < Q’, ∑, q0, δ’, F’ > can be constructed for language L as:

Step 1: Initially Q’ = ɸ.

Step 2: Add q0 to Q’.

Step 3: For each state in Q’, find the possible set of states for each input
symbol using transition function of NFA. If this set of states is not in Q’, add it
to Q’.

Step 4: Final state of DFA willBy Mr.K.Sankar


Presented be all Ganesh,
states withKNEC,contain
HOD&AP/CSE, VELLO F (final states of NFA)
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Minimization of DFA

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Example:

Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO


RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE
Presented By Mr.K.Sankar Ganesh, HOD&AP/CSE, KNEC, VELLO
RE

You might also like