Gate Toc Dfa

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Theory of Computation

1. Regular languages and finite automata

2. Context free languages and Push-down automata

3. Recursively enumerable languages and Turing

machines

4. Undecidability.

1 ELTP-GATE 2015
Models of Computation

2 ELTP-GATE 2015
Computation

CPU memory

3 ELTP-GATE 2015
temporary memory

input memory
CPU
output memory

Program memory

4 ELTP-GATE 2015
Example: f ( x) = x 3

temporary memory

input memory
CPU
output memory
Program memory
compute x∗x
compute x ∗x
2

5 ELTP-GATE 2015
f ( x) = x 3
temporary memory
input memory
x=2
CPU
output memory
Program memory
compute x∗x
compute x ∗x
2

6 ELTP-GATE 2015
temporary memory f ( x) = x 3

z = 2*2 = 4
f ( x) = z * 2 = 8
input memory
x=2
CPU
output memory
Program memory
compute x∗x
compute x ∗x
2
7 ELTP-GATE 2015
temporary memory f ( x) = x 3

z = 2*2 = 4
f ( x) = z * 2 = 8
input memory
x=2
CPU
f ( x) = 8
Program memory output memory
compute x∗x
compute x ∗x
2
8 ELTP-GATE 2015
Automaton
temporary memory

Automaton
input memory
CPU
output memory

Program memory

9 ELTP-GATE 2015
Different Kinds of Automata
Automata are distinguished by
the temporary memory

• Finite Automata: no temporary memory

• Pushdown Automata: stack

• Turing Machines: random access memory

10 ELTP-GATE 2015
Finite Automaton

temporary memory

input memory
Finite
Automaton
output memory
Example: Vending Machines, Control Unit in CPU
(small computing power)

11 ELTP-GATE 2015
Pushdown Automaton
Stack Push, Pop

input memory
Pushdown
Automaton
output memory

Example: Compilers for Programming Languages


(medium computing power)
12 ELTP-GATE 2015
Turing Machine

Random Access Memory

input memory
Turing
Machine
output memory
Examples: Any Algorithm
(highest computing power)
13 ELTP-GATE 2015
Computation Power of Automata

Finite Pushdown Turing


Automata Automata Machine

Less computation power More computation power


Solve more
computational problems

14
ELTP-GATE 2015
Finite Automata

15 ELTP-GATE 2015
Finite Automaton

Input
String

Output
Finite String
Automaton

16 ELTP-GATE 2015
Type of Finite Automaton
Acceptors and Transducers
Acceptor -- Only output = yes/no

Known as the "Moore" model

State-based output

Transducer -- Input/Output strings

Known as the "Mealy" model

Transition-based output

17 ELTP-GATE 2015
Finite Accepter

Input
String
Output
“Accept”
Finite
or
Automaton “Reject”

18 ELTP-GATE 2015
Transition Graph or State Diagram
abba -Finite Accepter a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4

initial final
state state
transition
state “accept”
19 ELTP-GATE 2015
Another Example
a a, b

q0 b q1 a, b q2

20 ELTP-GATE 2015
1. Deterministic Finite Automaton

Next-State Function

2. Non-Deterministic Finite Automaton

Next-State Relation

21 ELTP-GATE 2015
Formalities
Deterministic Finite Accepter (DFA)

M = (Q, Σ, δ , q0 , F )
Q : set of states
Σ : input alphabet
δ : transition function
q0 : initial state

F : set of final states


22 ELTP-GATE 2015
Input Alphabet Σ

Σ = {a, b}

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4

23 ELTP-GATE 2015
Set of States Q
Q = {q0 , q1, q2 , q3 , q4 , q5 }

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4

24 ELTP-GATE 2015
Initial State q0

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4

25 ELTP-GATE 2015
Set of Final States F

F = {q4 }

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4

26 ELTP-GATE 2015
Trap State
Any words with prefixes that take you to a
trap state will not be accepted
Example: Machine accepting words over {0,1}
that start with 0:
0,1
0

1
0,1 Trap State

27 ELTP-GATE 2015
Transition Function δ

δ :Q×Σ → Q

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4

28 ELTP-GATE 2015
δ (q0 , a ) = q1

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4

29 ELTP-GATE 2015
Transition Function δ
δ a b
q0 q1 q5
q1 q5 q2
q2 q2 q3
q3 q4 q5 a, b
q4 q5 q5
q5 q5 q5 q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
30 ELTP-GATE 2015
Extended Transition Function δ *

δ * : Q × Σ* → Q

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4

31 ELTP-GATE 2015
δ * (q0 , abba ) = q4

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4

32 ELTP-GATE 2015
Languages Accepted by DFAs
Take DFA M

Definition:
The language L( M ) contains
all input strings accepted by M

L(M ) = { strings that drive M to a final state}

33 ELTP-GATE 2015
Example
L(M ) = {abba} M

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
accept
34 ELTP-GATE 2015
Another Example
L(M ) = {λ , ab, abba} M

a, b

q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
accept accept accept
35 ELTP-GATE 2015
Formally

For a DFA M = (Q, Σ, δ , q0 , F )

Language accepted by M :

L(M ) = {w ∈ Σ* : δ * (q0 , w) ∈ F }

alphabet transition initial final


function state states
36 ELTP-GATE 2015
Observation
Language accepted by M :

L(M ) = {w ∈ Σ* : δ * (q0 , w) ∈ F }

Language rejected by M :

L(M ) = {w ∈ Σ* : δ * (q0 , w) ∉ F }

37 ELTP-GATE 2015
More Examples

L(M ) = {a b : n ≥ 0}
n

a a, b

q0 b q1 a, b q2

accept trap state

38 ELTP-GATE 2015
L(M ) = { all strings with prefix ab }
a, b

q0 a q1 b q2

b a accept

q3 a, b
39 ELTP-GATE 2015
L (M ) = { all strings without
substring 001 }

1 0 0,1
1

λ 0 1
0 00 001

0
40 ELTP-GATE 2015
1.

41 ELTP-GATE 2015
2.

42 ELTP-GATE 2015
3.For construct dfa’s that accept the sets
consisting of
(a) all strings with exactly one a,
(b) all strings with at least one a,
(c) all strings with no more than three a’s,
(d) all strings with at least one a and exactly
two b’s.
(e) all the strings with exactly two a’s and
more than two b’s.

43 ELTP-GATE 2015
Let ∑ = {a, b}. Define the language A = {w ∈ ∑* | w = sbab for some string s ∈ ∑*}.
Draw a DFA for A.

44 ELTP-GATE 2015
In each part of this question, Design an DFA that accepts the given language.
(a) The language of all strings ending with b.
(b) The language of all strings containing the substring bb.
(c) The language of all strings containing either the substring bb or the
substring baab.

45 ELTP-GATE 2015

You might also like