0% found this document useful (0 votes)
24 views50 pages

Toc Unit 1

This pdf is of theory of computation in 5th semester

Uploaded by

sambhavdwivedi48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views50 pages

Toc Unit 1

This pdf is of theory of computation in 5th semester

Uploaded by

sambhavdwivedi48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

THEORY OF COMPUTATION

CS 501
Btech 5th Sem.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
INTRODUCTION: Theory of Computation

It is the study of abstract machines and the computation


problems that can be solved using these machines. The
abstract machine is called the automata. An automaton with a
finite number of states is called a Finite automaton.
It mainly deals with the logic of computation with respect to
simple machines that solve some problems.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
UNIT :1

Introduction of Automata Theory: Examples of automata machines


Finite Automata as a language acceptor and translator
Moore machines and mealy machines
Conversion from Mealy to Moore and vice versa
composite machine

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Input alphabets set, String, Language
Input alphabets set:

Ex: ∑={0,1}

STRING:

A string over an alphabet set ∑ : is a finite sequence of symbols from ∑


Set of Strings={0,1,00,11,010,1110………….}

Example: Σ = {a, b, c, d} is an alphabet set where ‘a’, ‘b’, ‘c’, and ‘d’ are
symbols.

Set of Strings={a,b,b,d,ab,bc………….}

∑ * denotes the set of all strings (including ϵ or ᴧ , the empty string)


over the alphabet set ∑. That is, ∑ + = ∑ * - {ᴧ}

Language: Set of Strings.


L={0,1}
L1={00,10,01,11} finite
L={0,01,00,011, …………………} infinite

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Related Terminologies
Length of a String;
Definition : It is the number of symbols present in a string. (Denoted by
|S|).

Examples:
If S=‘cabcad’, |S|= 6
|S|= 0, it is called an empty string (Denoted by λ or ε)

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Kleene Star:
Definition: The Kleene star, Σ*, is a unary operator on a set of symbols or strings,
Σ, that gives the infinite set of all possible strings of all possible lengths over Σ
including λ. For Σ={a,b}, Σ0 ={λ}, Σ1 ={a,b}, Σ2 ={aa,ab,ba,bb},
Representation: Σ* = Σ0 U Σ1 U Σ2 U……. where Σp is the set of all possible strings
of length p.
Example: If Σ = {a, b}, Σ*= {λ, a, b, aa, ab, ba, bb,………..}
Kleene Closure / Plus:
Definition: The set Σ+ is the infinite set of all possible strings of all possible lengths
over Σ excluding λ.
Representation: Σ+ = Σ1 U Σ2 U Σ3 U…….
Σ+ = Σ* − { λ }
Example: If Σ = { a, b } , Σ+ ={ a, b, aa, ab, ba, bb,………..}
Language:
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, bb, ba, bb}
BY Prof. Om Singh Parihar , Department of
CSE, GGCT
DEFINITION OF AN AUTOMATON
An automaton is defined as a system where energy, materials
and information are transformed. transmitted and used for
performing some functions without direct participation of man.

Ex:
 automatic machine tools
 automatic packing machines
 and automatic photo
 printing machines

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
FINITE AUTOMATON
Definition
A finite automaton can be represented by a
5-tuple (Q, ∑, δ ,qo. F). Where
[ Deterministic FA]
(i) Q is a finite nonempty set of states.
(ii) ∑ is a finite nonempty set of inputs called the input alphabet.
(iii) δ is a transition function which maps Qx ∑ into Q .
(iv) qo ϵ Q is the initial state.
(v) F subset of Q is the set of final states

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
BY Prof. Om Singh Parihar , Department of
CSE, GGCT
Finite
Automata as a language acceptor
• DFA [DETERMINISTIC FINITE Automata ]or
DFSM[DETERMINISTIC FINITE STATE
MACHINES]
• NFA [NONDETERMINISTIC FINITE STATE
Automata] or NFSM[NONDETERMINISTIC
FINITE STATE MACHINES]

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Finite
Automata as a language acceptor

FA Acceptor (Recognizer):
FA is called Acceptor or Recognizer if it accepts a Language or Reject a
Language.

Ex: if L={ab,aa,bb,ba}
FA accepts a Language L if it accepts all strings w in L otherwise Rejects L.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
String w is accepted by FA
A string w is called accepted by FA if
δ(q0, w) ∈ F otherwise Rejected

• String w is accepted by FA if the configuration


(q0,w) yields the configuration (F,ϵ ) where F
is an accepting state or final state.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Problem: Construct a DFA for set of all strings starting with 1
over input alphabets Σ {0,1}

L={1,11,10,1111,10101,100,101,……….} infinite

FA=5-tuple (Q, ∑, δ ,qo. F).


Q={q0,q1,q2}
∑={0,1}
δ: Transition function : Qx ∑ -> Q
q0 initial state
F={q1}

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
δ: Transition function : Qx ∑ -> Q
δ (q0,1)=q1
δ (q0,0)=q2
δ (q1,0)=q1
δ (q1,1)=q1
δ (q2,0)=q2, δ (q2,1)=q2
Q0 0 Q0

Q1 1 Q1

Q2 Q2

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
State Transition Table

State 0 1
q0 q2 q1
q1 q1 q1
q2 q2 q2

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Accepting and Rejecting a string w

Accepting a String w
δ (q0,110)->δ (q1,10)->δ (q1,0)->δ (q1, ∈) q1 is final state
So 110 is accepted

Rejection of w=011
δ (q0,011)->δ (q2,11)->δ (q2,1)->δ (q2, ∈) q2 is non final state
So 011 REJECTED
BY Prof. Om Singh Parihar , Department of
CSE, GGCT
Example, below DFA with Σ = {0, 1} accepts all strings ending with 0.

L={0,10,100,1110,1010,100,10010,……….}
FA=5-tuple (Q, ∑, δ ,qo. F).
Q={q0,q1}
∑={0,1}
δ: Transition function : Qx ∑ -> Q , q0 initial state ,F={q1}
Transition Function:
δ (q0,1)=q0
δ (q0,0)=q1
δ (q1,0)=q1
δ (q1,1)=q0

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Starting with ab

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Containing ab

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Ending with ab

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Design a DFA in which start and end symbol must be different
Given: Input alphabet, Σ={a, b}
Language L = {ab, ab, abab, aabb, aaabbb,...}

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Design a DFA in which start and end symbol must be same
Given: Input alphabet, Σ={a, b}
Language L = {ε, a, b, aa, bb, aba, bab, ababa, aabba, aaabbba,...}

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Moore machines and mealy machines
[FA with output]

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Example Moore Machine

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
• Q={q0,q1,q2,q3}
• ∑={0,1}
• Δ is out put alphabets={0,1}
• δ is transition function that maps :Q x ∑->Q
as δ (q0,0)=q3 δ (q0,1)=q1
δ (q1,0)=q1 δ (q1,1)=q2
δ (q2,0)=q2 δ (q2,1)=q3
δ (q3,0)=q3 δ (q3,1)=q0

• λ is output function that Maps Q into Δ


as q0->0, q1->1, q2->0, q3->0
• q0: initial state

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
State Transition Table

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
MOORE MACHINE OUTPUT

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
In MOORE machine
NOTE:
1.Output function depends only on the present
state and is independent of the current input.

2.For a Moore machine if the input string is of


length n, the output string is of length n + 1.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Mealy Machine

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Mealy Machine Example

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
• Q={q1,q2,q3,q4}
• ∑={0,1}
• Δ is out put alphabets={0,1}
• δ is transition function that maps :Q x ∑->Q
as δ (q1,0)=q3 δ (q1,1)=q2
δ (q2,0)=q1 δ (q2,1)=q4
δ (q3,0)=q2 δ (q3,1)=q1
δ (q3,0)=q4 δ (q3,1)=q3

• λ is output function that Maps Q x ∑-> Δ


(q1,0/0) (q1,1/0)
(q2,0/1) (q2,1/0)
(q3,0/1) (q3,1/1)
(q4,0/1) (q4,1/0)

• q0: initial state BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Mealy Machine State Transition Table

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Mealy Machine Output

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Mealy machine for 1’s complement of
a Binary Number

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Mealy Machine for 2’s complement of
a Binary number

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
In Mealy Machine

NOTE:
1.The value of the output function depends on the present state
and the present input.

2.In the case of a Mealy machine if the input string is of length


n. the output string is also of the same length n.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Conversion from Mealy to Moore and vice versa
Q: for given mealy machine ,Construct Moore machine?

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
EQUIVALENTMOORE MACHINE FOR PREVIOUS MEALY MACHINE TABLE[3.10]

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
QUESTION

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
SOLUTION

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
NOW CONSTRUCTING EQUIVALENT MOORE MACHINE

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
REVISED MOORE MACHINE

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
NOTE
if we have an m-output and n state Mealy machine.
the corresponding m-output Moore machine has no more than
[mn +1] states.

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
MOORE TO MEALY CONVERSION

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
EQUIVALENT MEALY MACHINE

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
CONSTRUCT EQUIVALENT MEALY MACHINE FOR GIVEN
MOORE MACHINE

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
SOLUTION

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Construct Moore machine for given Mealy machine

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
State transition table for given Mealy machine

BY Prof. Om Singh Parihar , Department of


CSE, GGCT
Equivalent MOORE machine for given Mealy machine

BY Prof. Om Singh Parihar , Department of


CSE, GGCT

You might also like