0% found this document useful (0 votes)
40 views28 pages

Automata Questions With Solution

The document is a question bank for a course on Theory of Automata and Formal Languages, covering key concepts such as Automata, DFA, NFA, and their equivalences. It includes definitions, examples, and solutions to various questions related to finite automata, including the design of DFA and NFA for specific languages. The document also discusses Moore and Mealy machines, minimization of DFA, and provides examples of automata for specific patterns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views28 pages

Automata Questions With Solution

The document is a question bank for a course on Theory of Automata and Formal Languages, covering key concepts such as Automata, DFA, NFA, and their equivalences. It includes definitions, examples, and solutions to various questions related to finite automata, including the design of DFA and NFA for specific languages. The document also discusses Moore and Mealy machines, minimization of DFA, and provides examples of automata for specific patterns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

MEERUT INSTITUTE OF ENGINEERING AND

TECHNOLOGY
DEPARTMENT OF CSE

SUB: T.A.F.L. SUB CODE: BCS-402

QUESTION BANK: Imp Questions with their Solutions

Faculty Name: Mr. Vivek Kumar, Dr. Satendra Kumar,Mr. Ashu Singh

1. Define Automata. What is Theory of Computation?

Solution:

● Automata: An automaton (plural: automata) is an abstract mathematical model for


machines that can perform computations on an input to produce an output. It consists
of states and transitions between states.
● Theory of Computation (ToC): It is a branch of computer science that deals with
how problems can be solved using algorithms and how efficiently they can be solved.
It includes automata theory, formal languages, computability, and complexity theory.

2. Define Alphabet, Symbol, String, and Formal Language with examples.

Solution:

● Alphabet (Σ): A finite non-empty set of symbols.


Example: Σ = {0, 1}
● Symbol: An element of the alphabet.
Example: 0, 1 ∈ Σ
● String: A finite sequence of symbols from an alphabet.
Example: 101, 1100
● Formal Language: A set of strings formed from an alphabet according to certain
rules.
Example: L = {w | w contains even number of 0s}, Σ = {0,1}

3. Define Deterministic Finite Automaton (DFA). Give an example.


Solution:

● A DFA is a 5-tuple (Q, Σ, δ, q₀, F):


o Q = finite set of states
o Σ = input alphabet
o = transition function : Q × Q
o q₀ ∈ Q = initial state
o F ⊆ Q = set of accepting states

Example DFA: Accepts strings ending with 1 over Σ={0,1}

● Q = {q0, q1}
● q0 = initial state
● F = {q1}
● δ:

δ(q0,0) = q0 δ(q0,1) = q1
δ(q1,0) = q0 δ(q1,1) = q1

4. Define Nondeterministic Finite Automaton (NFA). How is it different from


DFA?

Solution:

● NFA: A 5-tuple (Q, , , q, F) where : Q × 2^Q.


● Difference:
o DFA has exactly one transition for each symbol in Σ from a state.
o NFA can have multiple or no transitions for a symbol.
o NFA can have ε-transitions (transitions without input).

5. Prove that DFA and NFA are equivalent.

Solution

● Every NFA can be converted to an equivalent DFA using the subset construction
method:
o Each DFA state represents a subset of NFA states.
o DFA simulates all possible moves of the NFA simultaneously.

6. What is NFA with ε-transitions? How can it be converted to NFA without ε?

Solution:

● NFA-ε: An NFA that allows transitions without consuming input (ε-transitions).


● Conversion:
o Compute ε-closure for each state.
o Modify transition function to include ε-closure states.
o Adjust final states if ε-closure contains final state.

7. Define Moore and Mealy machines. What is their equivalence?

Solution:

● Moore Machine: Output depends on the current state.


● Mealy Machine: Output depends on the current state and input symbol.
● They are equivalent because any Moore machine can be converted to a Mealy
machine and vice versa.

8. Explain minimization of DFA with example.

Solution:

Steps:
1-Remove unreachable states.
2-Partition states into groups: {final states} and {non-final states}.
3-Refine partitions until no more changes occur (distinguish states).

Example:
Given DFA:

mathematica
CopyEdit
States = {A,B,C,D}, Final={C}
Transitions:
A-0B, A-1C
B-0A, B-1D
C-0C, C-1C
D-0C, D-1C

Partition: {C}, {A,B,D}


After refinement: {C}, {A}, {B,D}

9. What is the difference between Mealy and Moore machine?


Moore
Feature Mealy Machine
Machine
Output depends Current state +
Current state
on input
On state
Output changes On transition
change
Generally More states Fewer states
10. Example of DFA accepting strings with even number of 0s over Σ={0,1}.

Solution:

Q = {q0, q1}
q0 = initial, final
q1 = non-final
δ:

δ(q0,0)=q1 δ(q0,1)=q0
δ(q1,0)=q0 δ(q1,1)=q1

Question 11.
Question 12.
Question 13
Question 14:
Question 15:

Question 16:

Question 17:
Draw a deterministic and non-deterministic finite automate which accept
00 and 11 at the end of a string containing 0, 1 in it, e.g., 01010100 but
not 000111010. Explanation - Design a DFA and NFA of a same string if
input value reaches the final state then it is acceptable otherwise it is not
acceptable. NFA of the given string is as follows:

DFA of the given string is as follows:

Here, q0 shows the initial


state, q1 and q2 are the transition states, and q3 and q4 are the final
states. Note - NFA and DFA both have same power that means if NFA can
recognized an language L then DFA can also be defined to do so and if
DFA can recognized an language L then NFA can also be defined to do
so. Que-2: 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". Explanation - Design a DFA and NFA of a same
string if input value reaches the final state then it is acceptable otherwise
it is not acceptable. It is applicable for all the DFA and NFA. Since, NFA is
quit easier then DFA, so first make its NFA and then go through the DFA.

NFA of the given string is as follows: DFA


of the given string is as follows:
Here, q0 shows the initial state, q1 and q2 are the transition states,
and q3 is the final state. Que-3: Draw a deterministic and non-
deterministic finite automata which accept a string containing "ing" at the
end of a string in a string of {a-z}, e.g., "anything" but not
"anywhere". Explanation - Design a DFA and NFA of a same string if
input value reaches the final state then it is acceptable otherwise it is not
acceptable. It is applicable for all the DFA and NFA. NFA of the given

string is as follows: DFA of the given string is as

follows: Here, q0 shows the initial


state, q1 and q2 are the transition states, and q3 is the final state.

Question 18:

Design a DFA for the following language L = { 0m 1 n | m 0 and n 1}

Solution: We are given the language:

L = { 0^m 1^n | m 0 and n 1 }

Step-by-step Breakdown:

This language includes:

● Any number (including 0) of 0s


● Followed by at least one 1 (i.e., one or more 1s)
● No other characters or mixing of 0s and 1s (e.g., no 0101, no 1s before 0s)
Key observations:

● All 0s must come before any 1s.


● At least one 1 must appear.
● Once a 1 is seen, no more 0s are allowed.

DFA Design:

We’ll define the DFA as a 5-tuple:


DFA = (Q, Σ, δ, q₀, F)

● Q: Set of states
● Σ: Input alphabet = {0, 1}
● δ: Transition function
● q₀: Start state
● F: Set of accepting states

States:

Let’s define the following states:

● q₀: Start state, where we can see any number of 0s


● q₁: We’ve seen the first 1 (i.e., the first valid point for acceptance)
● q₂: We’re seeing more 1s (still valid)
● q_dead: Dead state (invalid input, e.g., a 0 after a 1)

Transitions:

Current Inp Next


State ut State
q₀ 0 q₀
q₀ 1 q₁
q₁ 1 q₁
q₁ 0 q_dead
q_dead 0 q_dead
q_dead 1 q_dead
Accepting States:

● F = {q₁}

DFA Diagram (Text Representation):


0 1
+------+ +------+
| v v |
--> [q₀] -----> [q₁] ----+
^ |
| v
+--(0)--> [q_dead]

Example Valid Strings:

● 1 q q ✅
● 01 q q q ✅
● 0011 q q q q q ✅

Example Invalid Strings:

● 0 q (no 1s at all) ❌
● 10 q q q_dead ❌

Question 19:

Construct a Moore and Melay Machine to accept modulo 5 counter for binary inputs.

Sol: In a Moore machine, the output depends solely on the current state, not on the input. For
a modulo-5 counter, we need to design a 3-bit counter that resets after counting up to 4
(binary 100).
States and Outputs
● States (S): 5 states representing counts 0 to 4.
● Output (O): The output can be the binary representation of the current count.

State Diagram
markdown
Copy code
S0 (000) S1 (001) S2 (010) S3 (011) S4 (100)
________________________________________________
● Transitions: On each clock pulse, the counter increments by 1.
● Reset: After reaching state S4 (100), the counter resets to state S0 (000).

State Transition Table


Current Inp Next Outp
State ut State ut
S0 (000) 1 S1 (001) 000
S1 (001) 1 S2 (010) 001
S2 (010) 1 S3 (011) 010
S3 (011) 1 S4 (100) 011
S4 (100) 1 S0 (000) 100

⚙️Mealy Machine for Modulo-5 Counter


In a Mealy machine, the output depends on both the current state and the input. For a
modulo-5 counter, we can design a similar state diagram but with outputs associated with
transitions.
States and Outputs
● States (S): 5 states representing counts 0 to 4.
● Output (O): The output can be the binary representation of the current count.

State Diagram
markdown
Copy code
S0 (000) S1 (001) S2 (010) S3 (011) S4 (100)
________________________________________________
● Transitions: On each clock pulse, the counter increments by 1.
● Outputs: The output is the binary representation of the current state.

State Transition Table


Current Inp Next Outp
State ut State ut
S0 (000) 1 S1 (001) 000
S1 (001) 1 S2 (010) 001
S2 (010) 1 S3 (011) 010
S3 (011) 1 S4 (100) 011
S4 (100) 1 S0 (000) 100

Question:20

Define NFA with epsilon with an example.

Sol: Definition: NFA with Epsilon (ε-NFA)


An ε-NFA (Epsilon-NFA) is a Nondeterministic Finite Automaton that allows transitions
without consuming any input symbol. These are called epsilon transitions (ε-transitions).
✳️Why use ε-transitions?
They allow the automaton to:
● Jump between states "for free" (without reading input)

● Split paths nondeterministically


● Simplify design (especially useful in regex to NFA conversion)

🧠 Formal Definition
An ε-NFA is a 5-tuple:
M = (Q, Σ, δ, q₀, F)
Where:
● Q = finite set of states

● Σ = input alphabet
● δ = transition function:
δ: Q × (Σ ∪
{}) P(Q)
set of states)
● q₀ ∈ Q = start state
● F ⊆ Q = set of accepting states

✅ Example: Language L = {a, ab}


We want to build an ε-NFA that accepts:
● The string "a"

● Or the string "ab"

💡 States:
Let’s define the states:
● Q = {q0, q1, q2, q3}

● Σ = {a, b}
● Start state: q0
● Accepting states: F = {q1, q3}

🔁 Transition function δ:
Fro Inp T
m ut o
q
q0 ε
1
q
q0 ε
2
Fro Inp T
m ut o
q1 a —
q
q2 a
3
q3 b —

🧾 Explanation:
● From q0, the machine can:
o Jump to q1 with ε and accept a directly
o Or jump to q2 with ε, then read a, go to q3, then read b and accept ab
So this ε-NFA accepts both:
● "a" (via q0 q1 accept)

● "ab" (via q0 q2 a q3 b accept)

✅ Accepting Strings:
● Input a
:
⇒ accept ✔️
● Input ab
:
⇒ accept ✔️
● Input b: no path ⇒ reject ❌
● Input aa: no full path ⇒ reject ❌

Question:21

Construct a DFA with reduced states equivalent to the regular expression 10 + (0 + 11)0* 1

Sol: Regular Expression:


10+(0+11)0∗110 + (0 + 11)0^*110+(0+11)0∗1

🔍 Step 1: Understand the Language


The regular expression is:
10 + (0+11)0∗110 \;+\; (0 + 11)0^*110+(0+11)0∗1
This means:
● The language accepts either:
1. The string "10"
OR
2. Strings that:
▪ Start with 0 or 11

▪ Followed by zero or more 0s


▪ End with 1
So the accepted strings include:
● "10" (first part)

● "01" 0+ +1
● "001" 0+0+1
● "0001" 0 + 00 + 1
● "1101" 11 + 0 + 1
● "11001"
11 + 00 + 1

Step 2: Build an NFA (or ε-NFA)


We'll design a basic NFA for the expression, and then convert it to a DFA and minimize it.

✅ Step 3: Build DFA


We now construct a DFA directly for:
L={10}∪{(0+11)0∗1}L = \{ 10 \} \cup \{ (0 + 11)0^*1 \}L={10}∪{(0+11)0∗1}
Let’s define states to capture both branches.

🔹 State Definitions:
Let’s name states informally first:
● q0: Start

● For "10":
o q0 1 q1 0 q_accept
● For (0 + 11) 0* 1:
o Case 0...1:
▪ q0 0 q2 0* q3 1 q_accept
o Case 11...1:
▪ q0 1 q4 1 q2 (same q2 as above) 0* q3 1
q_accept

We will now formalize this into a deterministic automaton.

💡 DFA Construction
Let’s define DFA states as sets of possibilities (subset construction):
We'll walk through all possibilities manually to build a DFA.
🧾 State List and Transitions:
Let’s define the following DFA states:
Sta
Description
te
A Start state
B Seen 1 (possible start of "10" or "11")
C Seen 10 ⇒ Accept (for "10")
D Seen 0 (start of (0+11)0*1)
E Seen 11 ⇒ move to 0* state
F In 0* (after 0 or 11)
Seen final 1 ⇒ Accept (from
G
(0+11)0*1)
Z Dead state (for invalid strings)

📋 Transition Table:
Curre Inp Ne
Notes
nt ut xt
A 0 D Start 0 path
A 1 B Start 1 path
B 0 C 10 ⇒ Accept
B 1 E Seen 11
C 0 Z Dead after 10
C 1 Z Dead after 10
D 0 F Start 0*
D 1 G Accept 01
E 0 F Start 0*
E 1 Z No valid transition from 111
F 0 F Looping in 0*
F 1 G Accepting final 1
Final accept; no further input
G 0 Z
allowed
Final accept; no further input
G 1 Z
allowed
Z 0 Z Dead state
Z 1 Z Dead state

✅ Accepting States:
● C (for string "10")
● G (for strings matching (0 + 11)0*1)

✂️Step 4: Minimize DFA


We can minimize states by grouping:
1. Accepting states: {C, G}
2. Non-accepting, non-dead: {A, B, D, E, F}
3. Dead state: {Z}
Apply partitioning minimization — but in this DFA, most states have unique roles, so it is
already minimal.

🏁 Final Answer:
✅ DFA with reduced states that accepts the regular expression:
10+(0+11)0∗110 + (0 + 11)0^*110+(0+11)0∗1
States:
A, B, C, D, E, F, G, Z
Alphabet: {0, 1}
Start state: A
Accepting states: {C, G}
Question:22

Draw the transition table, transition diagram, transition function of DFA a) Which accepts
strings which have odd number of a’s and b’s over the alphabet {a,b} b) Which accepts string
which have even number of a’s and b’s over the alphabet {a,b} c)Which accepts all strings
ending in 00 over alphabet {0, 1} d)Which accepts all strings having 3 consecutive zeros? e)
Which accepts all strings having 5 consecutive ones? f) Which accepts all strings having even
number of symbols.

Sol: Certainly! Let's design Deterministic Finite Automata (DFA) for each of the specified
languages over the given alphabets. For each case, I'll provide:

● Transition Table
● Transition Diagram
● Transition Function

a) DFA that accepts strings with an odd number of 'a's and 'b's over the
alphabet {a, b}

Transition Table:

Current Input Input Next


State 'a' 'b' State
q0 q1 q2 q1, q2
q1 q0 q3 q0, q3
q2 q3 q0 q3, q0
q3 q2 q1 q2, q1

Transition Diagram:

q0 --a--> q1 --b--> q3 --a--> q2 --b--> q1


| | | | |
+--------+--------+--------+--------+
Transition Function:

● δ(q0, a) = q1
● δ(q0, b) = q2
● δ(q1, a) = q0
● δ(q1, b) = q3
● δ(q2, a) = q3
● δ(q2, b) = q0
● δ(q3, a) = q2
● δ(q3, b) = q1

b) DFA that accepts strings with an even number of 'a's and 'b's over the
alphabet {a, b}

Transition Table:

Current Input Input Next


State 'a' 'b' State
q0 q1 q2 q1, q2
q1 q0 q3 q0, q3
q2 q3 q0 q3, q0
q3 q2 q1 q2, q1

Transition Diagram:

q0 --a--> q1 --b--> q3 --a--> q2 --b--> q1


| | | | |
+--------+--------+--------+--------+

Transition Function:

● δ(q0, a) = q1
● δ(q0, b) = q2
● δ(q1, a) = q0
● δ(q1, b) = q3
● δ(q2, a) = q3
● δ(q2, b) = q0
● δ(q3, a) = q2
● δ(q3, b) = q1
c) DFA that accepts strings ending in "00" over the alphabet {0, 1}

Transition Table:

Current Input Input Next


State '0' '1' State
q0 q1 q0 q1, q0
q1 q2 q0 q2, q0
q2 q2 q0 q2, q0

Transition Diagram:

q0 --0--> q1 --0--> q2
| | |
+--------+--------+

Transition Function:

● δ(q0, 0) = q1
● δ(q0, 1) = q0
● δ(q1, 0) = q2
● δ(q1, 1) = q0
● δ(q2, 0) = q2
● δ(q2, 1) = q0

d) DFA that accepts strings containing "000" (3 consecutive zeros) over the
alphabet {0, 1}

Transition Table:

Current Input Input Next


State '0' '1' State
q0 q1 q0 q1, q0
q1 q2 q0 q2, q0
q2 q3 q0 q3, q0
q3 q3 q0 q3, q0
Transition Diagram:

q0 --0--> q1 --0--> q2 --0--> q3


| | | |
+--------+--------+--------+

Transition Function:

● δ(q0, 0) = q1
● δ(q0, 1) = q0
● δ(q1, 0) = q2
● δ(q1, 1) = q0
● δ(q2, 0) = q3
● δ(q2, 1) = q0
● δ(q3, 0) = q3
● δ(q3, 1) = q0

e) DFA that accepts strings containing "11111" (5 consecutive ones) over the
alphabet {0, 1}

Transition Table:

Current Input Input Next


State '0' '1' State
q0 q0 q1 q0, q1
q1 q0 q2 q0, q2
q2 q0 q3 q0, q3
q3 q0 q4 q0, q4
q4 q0 q5 q0, q5
q5 q5 q5 q5, q5

Transition Diagram:

q0 --1--> q1 --1--> q2 --1--> q3 --1--> q4 --1--> q5


| | | | | |
+--------+--------+--------+--------+--------+

Transition Function:

● δ(q0, 0) = q0
● δ(q0, 1) = q1
● δ(q1, 0) = q0
● δ(q1, 1) = q2
● δ(q2, 0) = q0
● δ(q2, 1) = q3
● δ(q3, 0) = q0
● δ(q3, 1) = q4
● δ(q4, 0) = q0
● δ(q4, 1) = q5
● δ(q5, 0) = q5
● δ(q5, 1) = q5

f) DFA that accepts strings with an even number of symbols (i.e., even length)
over the alphabet {0, 1}

Transition Table:

Current Input Input Next


State '0' '1' State
q0 q1 q1 q1
q1 q0 q0 q0

Transition Diagram:

q0 --0--> q1 --0--> q0
| | |
+--------+--------+

Transition Function:

● δ(q0, 0) = q1
● δ(q0, 1) = q1
● δ(q1, 0) = q
● δ(q1, 1) = q0

Question:23

Construct NFA which accepts the set of all strings over f0; 1g in which there are at least two
occurrences of 1 between any two occurrences of 0. Construct DFA for the same set.

Sol: We are asked to construct an NFA and then a DFA for the language:
L = { w ∈ {0,1} | there are at least two 1s between any two 0s }*
✅ Step 1: Understanding the Language
The strings must follow the rule:
Between any two 0s, there must be at least two 1s.

✔ Valid Examples:
● 1, 11, 0, 0110, 01110, 101110, 1101101

● Any string with:


o 0s isolated or
o 0s separated by 2 ones

❌ Invalid Examples:
● 00 0 followed immediately by 0
● 010 only 1 one between 0s
● 01 only one 1 after 0, next is 0 or end (unless last 0)

✅ Step 2: Design an NFA


We build an NFA that:
● Allows arbitrary sequences of 1s

● On a 0, requires at least two 1s before another 0 can appear

🔹 States:
Let’s define the states:
Sta
Meaning
te
q0 Start state (no recent 0)
q1 Just saw a 0, need first 1
q2 Saw one 1 after 0, need second 1
Saw two 1s after 0, can now see another
q3
0

🔁 NFA Transitions:
Fro Inp T
Explanation
m ut o
q
q0 1 Stay on 1
0
q
q0 0 Saw a 0 must enforce 2 1s next
1
q
q1 1 First 1 after 0
2
q
q2 1 Second 1 after 0
3
q3 1 q Additional 1s
Fro Inp T
Explanation
m ut o
3
q
q3 0 Next 0 allowed re-enter 0 state
1

🟩 Start State: q0
🟦 Accepting States: {q0, q3}
● q0: Valid start and all-1 strings
● q3: After valid spacing between 0s

✅ Step 3: Convert to DFA


We convert the NFA to DFA using subset construction.

💠 DFA States as Subsets:


Let’s define combined states from NFA:
DFA
Meaning
State
A = {q0} Start
B = {q1} After 0, need 1
C = {q2} After 1, need second 1
Saw 2 1s after 0, allowed next
D = {q3}
0
We now compute transitions:
Fro Inp T
m ut o
A 1 A
A 0 B
B 1 C
C 1 D
D 1 D
D 0 B
Unreachable states beyond these, so DFA is:

💠 DFA Transition Table:


Sta Input Input
te 0 1
A B A
B — C
C — D
D B D
(If undefined, we can route to dead state Z if desired.)
✅ Accepting States in DFA: A and D

📘 Final Summary
✅ NFA:
● States: q0, q1, q2, q3
● Start: q0
● Accept: q0, q3
● Logic: Require 2 1s between 0s

✅ DFA:
● States: A, B, C, D
● Start: A
● Accept: A, D
● Transitions:
A --0--> B
A --1--> A
B --1--> C
C --1--> D
D --1--> D
D --0--> B

Question:24

Design a Moore machine to determine the residue mod 5 for each binary string treated as
integer.

Sol: ✅ Problem Statement:


Design a Moore machine that computes the residue modulo 5 of a binary string
(interpreted as a binary number). That is:
Given a binary string (e.g., "1011" = 11 in decimal), the machine should output the value of:
integer value of the string mod 5\text{integer value of the string} \bmod
5integer value of the stringmod5

🔢 Key Concepts:
● A Moore machine is a 6-tuple:

M=(Q,Σ,Δ,δ,λ,q0)M = (Q, \Sigma, \Delta, \delta, \lambda, q_0)M=(Q,Σ,Δ,δ,λ,q0)

Where:
o Q: Set of states
o Σ: Input alphabet (here: {0,1})
o Δ: Output alphabet (here: {0,1,2,3,4})
o δ : Transition function Q×QQ \times \Sigma \rightarrow QQ×Q
o λ : Output function QQ \rightarrow \DeltaQ
o q₀: Initial state

💡 Idea:
We simulate the binary number being built left to right. After each bit, compute the residue
mod 5 of the number seen so far.
Let:
● q₀ = state where the value so far is 0 mod 5

● q₁ = 1 mod 5
● q₂ = 2 mod 5
● q₃ = 3 mod 5
● q₄ = 4 mod 5
On reading bit b, and in current state qᵢ, the new value is:
new value=(2×i+b)mod 5\text{new value} = (2 × i + b) \mod 5new value=(2×i+b)mod5

🔁 Transition Table:
Let’s construct the transition function (δ) and the output function (λ):
📘 δ: State transitions for each bit
Current Input Input
State '0' '1'
q₀ (0) q₀ q₁
q₁ (1) q₂ q₃
q₂ (2) q₄ q₀
q₃ (3) q₁ q₂
q₄ (4) q₃ q₄
📗 λ: Output at each state
Sta Outp
te ut
q₀ 0
q₁ 1
q₂ 2
q₃ 3
q₄ 4

✅ Moore Machine Summary


● States: Q = {q₀, q₁, q₂, q₃, q₄}
● Alphabet: Σ = {0, 1}
● Start state: q₀
● Output function: λ(qᵢ) = i
● Transition function:
δ(qi,b)=(2⋅i+b)mod 5\delta(q_i, b) = (2 \cdot i + b) \mod 5δ(qi,b)=(2⋅i+b)mod5

🧪 Example:
Input: 1011 (which is 11 in decimal)
Let's simulate step-by-step:
● Start at q₀ (value = 0) Output: 0

● Read 1 : (2×0 + 1) % 5 = 1 q Output: 1


● Read 0 : (2×1 + 0) % 5 = 2 q Output: 2
● Read 1 : (2×2 + 1) % 5 = 0 q Output: 0
● Read 1 : (2×0 + 1) % 5 = 1 q Output: 1
✅ Final output: 1 , which is 11 mod 5 = 1 ✔ Correct
Question:25

Give a description about FA with empty moves.

Sol: ✅ Finite Automaton with Empty Moves (ε-NFA)


A Finite Automaton with empty moves is also known as an ε-NFA (epsilon-NFA), where ε
(epsilon) represents an empty string transition — a move that the automaton can make
without consuming any input symbol.

📘 Formal Definition
An ε-NFA is a 5-tuple:
M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)M=(Q,Σ,δ,q0,F)
Where:
● Q: A finite set of states

● Σ: Input alphabet (symbols from which strings are made)


● δ: Transition function:

δ:Q×(Σ∪
{})P(Q)\delta: Q \times (\Sigma \cup \{\varepsilon\}) \rightarrow P(Q):Q×(
∪ {})P(Q)

Meaning: Given a state and a symbol (or ε), return a set of states
● q₀: Start state

● F: Set of accepting (final) states

💡 What Makes ε-NFA Special?


● Allows transitions without consuming input (called ε-transitions)
● The automaton can “guess” future input patterns by transitioning on ε
● Can explore multiple computation paths in parallel
● Often used in regex-to-NFA constructions (Thompson’s construction)

🔁 Example
Let’s say we want to build an automaton for the regular expression:
L={a,ab}L = \{ a, ab \}L={a,ab}
An ε-NFA for this might look like:
rust
Copy code
q0 --ε--> q1 --a--> q3
\
ε--> q2 --a--> q4 --b--> q5
● Accepting states: q3 and q5
● Input "a" : q0 q1 a q3 ✅
● Input "ab" : q0 q2 a q4 b q5 ✅

📌 ε-Closure
To process input in an ε-NFA, we often compute the ε-closure of a state — the set of all
states reachable from that state using only ε-transitions.
This helps simulate an ε-NFA as an NFA or DFA.

🛠 Converting ε-NFA to NFA or DFA


● Any ε-NFA can be converted to a standard NFA (no ε-transitions)
● Any NFA (ε or not) can be converted to a DFA
● Thus: ε-NFA, NFA, and DFA all recognize the same class of languages — the
regular languages

You might also like