Unit 1 4
Unit 1 4
Foundations of Computations
Course Instructor
Dr. Umadevi V
Department of CSE, BMSCE
Webpage:https://sites.google.com/site/drvumadevi/
Example:
Event1/ Notations
Action1
State1 State3
Start State
Event3/
Event2/ Action3
Action2 State
State2
Final State
Nodes: State
Edges: Transition
Edge Label: Events / Actions
H
I TC
SW
BATTERY
input: switch
output: light bulb
actions: flip
switch
states: on, off
A simple “computer”
I TC
H Abstract machine or
SW
Automaton
f
input: switch
output: light bulb bulb is on if and only
if there was an odd
actions: f for “flip number of flips
switch”
states: on, off
Another “computer”
BATTERY
2
Another “computer”
1
1 start off off
2
BATTERY
2
off on
2 2 2 2
BATTERY
1
2
off on
1
1 4
?
5
BATTERY
Strings
Concatenation of Strings: Let x and
y be strings. Then xy denotes the
string obtained by concatenating x
with y, that is, xy is the string obtained
by appending the sequence os symbols
of y to that of x. e.g. if x = aab and y =
bbab, then xy = aabbbab. Note that xy
≠ yx.
1.22
Languages
Theory of Automata by
some Σ*, where Σ is a particular alphabet, is
called a language. If Σ is an alphabet, and L
Σ* , then L is a language over Σ.
An example is English, where the collection of
legal English words is a set of strings over the
alphabet that consists of all the letters.
1.23
Question
Consider the alphabet set as Σ ={0,1}. Write
down possible strings of the Language, L, which is
defined as follows:
L={w | w consists of equal number of 0’s and 1’s}
Answer:
L={ε, 01, 10, 1100, 0011, 0101, 1010, 0011010,
……..}
q0 a q1
q0 a q1
Transition Table
d a
q0 q1
q1 q0
February 20, 2025 CSE, BMSCE 39
Construct a Deterministic Finite Automata (DFA) to recognize all
odd number a’s given the alphabet set as Σ ={a}
q0 a q1 a q2
q0 a q1 a q1
b b b
a
Step8: For the missing transitions identified in step7, connect this transitions
to appropriate state so that the string stated in the problem is accepted.
b a
q0 a q1 a q2 Transition Diagram
b
b
q0
Answer: (B)
0
February 20, 2025 CSE, BMSCE 67
Question
Draw a deterministic finite automata which accept
a string containing “the” anywhere in a string of
Σ ={a-z}, e.g., “there” but not “those”.
Possible Remainders
Na(w) mod 3: { 0, 1, 2}
Nb(w) mod 2: { 0, 1}
OR
Design a DFA to accept the binary numbers which are
divisible by 3
r=2
i={0,1,2}
d={0,1}
k=3
OR
Design a DFA to accept the binary numbers which are
divisible by 5
Answer: a
Explanation: For a string of n characters with no repetitive
substrings, the number of states required to pass the string
is n+1.
Answer
q0 1 q01 0 q010
0
0 1
qe 0, 1
1 0, 1
q1 qdie
0, 1
Examples
Construct a DFA over alphabet {0, 1}
that accepts all strings that end in
101
…
qe
1 q101
0 q10
1
q1 …
…
1
q11 1
q111 1
February 20, 2025 CSE, BMSCE 111
Unit-1
Suppose in life,
Whenever you had a choice, you
could try both possibilities and live
your life.
At the end, you would go back and
choose the one that worked out the
best.
Formal Definition of an NFA
Given an NFA MNFA= (Q nfa , S, d nfa, q0, F nfa) which accepts the language L, find an
equivalent DFA MDFA= (Q dfa, S, d dfa , q0, F dfa) such that
L(MNFA) =L(MDFA)
Step-1: Identify the start state of the DFA . Since q o is the start state of NFA,
{q0} is the start state of DFA
Step-2: Identify the alphabets of DFA. The input alphabets of NFA are the input
alphabets of DFA
Step-3: Identify the QDFA , which are the states of DFA
The set of subsets of QNFA will be the states of DFA QDFA
Example:
QNFA ={q0 , q1 , q2 }
QDFA ={∅ , {q0} , {q1} , {q2}, {q0 , q1 } , {q0 , q2 } …..}
Step-4: Identify the final states of DFA
If {qi , qj, …qk} is the state of DFA then {qi , qj, …qk} will be final state of DFA
provided one of qi , qj, …qk is the final state of NFA
Step-5: Identifying transitions of DFA
For each state {qi , qj, …qk} in QDFA and for each input symbol ‘a’ in S , the
transition can be obtained as shown below
dDFA ({qi , qj, …qk} , a) = {dNFA (qi, a) U dNFA (qj, a) ……..}
February 20, 2025 CSE, BMSCE 121
Converting NFA to DFA using subset construction method
S ={a, b} , q0 = q0 , FNFA={q2}
dNFA: Q × S → 2Q dDFA a b
Transition Table
dNFA a b
q0 {q0, q1} {q0}
q1 ∅ {q2}
q2 ∅ ∅
Answer
Answer: a
Explanation: Statement 1 and 2 always true for a given
Language.
Answer: a
Explanation: The conversion of a non-deterministic
automata into a deterministic one is a process we
call subset construction or power set construction.
NFA
Answer
Answer
DFA
Converting NFA to DFA using subset construction method
Homework Problem
1
0
February 20, 2025 CSE, BMSCE 158
Question
Draw a deterministic and non-deterministic finite automata which
accept a string containing “the” anywhere in a string of {a-z}, e.g.,
“there” but not “those”.
Note:
- Transition in ε – NFA is allowed to make a transition spontaneously without
receiving an input symbol.
- ε-NFA’s are closely related to regular expressions.
- ε-NFA’s are useful in proving the equivalence between the classes of
language accepted by finite automate and by regular expressions
de +,- . 0-9 ε
q0 {q1} ∅ ∅ {q1}
q1 ∅ {q2} {q1 ,q4} ∅
q2 ∅ ∅ {q3} ∅
q3 ∅ ∅ {q3} {q5}
q4 ∅ {q3} ∅ ∅
q5 ∅ ∅ ∅ ∅
= (Qd , S, dd , qd , Fd )
D dd +,- . 0-9
= {. , + , - , 0, 1, 2, 3 ,4,5 ,6, 7, 8, 9}
qd = ε -Closure(q0)
(A) Φ
(B) ε
(C) a
(D) {a, ε}
Answer (B)
The given alphabet ∑ contains only one symbol {a} and the
given NFA accepts all strings with any number of occurrences
of ‘a’. In other words, the NFA accepts a+. Therefore
complement of the language accepted by automata is empty
string.