Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
18 views17 pages

Solution Module 1&2

The document compares Deterministic Finite Automata (DFA) with Non-deterministic Finite Automata (NFA), defining key characteristics and differences. It also covers formal definitions of finite automata, transition tables, and graphs, as well as concepts like Kleene closure, positive closure, and compatibility graphs. Additionally, it discusses the conversion between Moore and Mealy machines, the construction of DFAs for specific string patterns, and the applications of DFA in various computational contexts.
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)
18 views17 pages

Solution Module 1&2

The document compares Deterministic Finite Automata (DFA) with Non-deterministic Finite Automata (NFA), defining key characteristics and differences. It also covers formal definitions of finite automata, transition tables, and graphs, as well as concepts like Kleene closure, positive closure, and compatibility graphs. Additionally, it discusses the conversion between Moore and Mealy machines, the construction of DFAs for specific string patterns, and the applications of DFA in various computational contexts.
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/ 17

Module 1 & 2

1. Compare DFA with NFA


(NDFA) Non deterministic Finite
Aspect DFA (Deterministic Finite Automata)
Automata

On each input symbol, transitions to Can transition to multiple states or none


State Transition
exactly one state on the same input symbol

Determinism and Each state has an unique transition for A state can have multiple transitions for
Uniqueness each input symbol the same input symbol

Always has a single, unique May have multiple computation paths for
Computation Path
computation path for any input string the same input string

Ease of Generally simple and more Can be more complex to construct due to
construction straightforward to construct non-determinism

Acceptance of Accepts an input if it reaches a final Accepts an input if at least one


input state after processing all input computation path reaches a final state

2. Define finite automata (formal definition).


A deterministic finite automata (DFA) is defined by 5-tuple (Q, Σ, δ, S, F) where:

Q is a finite and non-empty set of states.

Σ is a finite non-empty set of finite input alphabet

δ is a transition function, (δ: Q × Σ → Q)

S is initial state (always one) (S ∈ Q)


F is a set of final states (F ⊆ Q) (0≤|F|≤N, where n is the number of states)
3. Illustrate briefly about the alphabet, string, powers of an alphabet and concatenation of strings.
Alphabet: An alphabet is a finite set of symbols, often denoted by Σ (sigma). For example, Σ = {a, b} represents an
alphabet consisting of two symbols, 'a' and 'b'.
String: A string is a finite sequence of symbols drawn from an alphabet. For instance, if Σ = {a, b}, then "abba" is a string
over Σ.
Powers of an Alphabet: The powers of an alphabet refer to the set of all possible strings of a given length formed using
symbols from the alphabet. Σk is the set of all strings from the alphabet Σof length exactly K.
For example, Σ² (Σ raised to the power of 2) consists of all strings of length 2, such as "aa", "ab", "ba", and "bb".
Concatenation of Strings: The concatenation of two strings results in a new string formed by appending the second string
to the first. For example, if x = "ab" and y = "ba", then their concatenation, denoted as xy, is "abba".

4. Explain transition table and transition graph with an example.

Transition Diagram
A transition diagram or a transition system is a finite directed labelled graph in which each circle represents a state and the
directed edges indicate the transition of one state to another state. The initial state is represented by a circle with an arrow
pointing towards it, the final state by two concentric circles.

Module 1 & 2 1
Transition Table
It is a two dimensional table where number of columns equal to the number of input alphabets and number or rows equal to
number of states.

a b

→q0 q1 q0

q1 q1 q0

5. Compute the below finite automata and check if the strings are accepted or
not (i) 1110, (ii) 0001, (iii) 1010

(i) 1110 - False


(ii) 0001 - False

(iii) 1010 - False

6. Develop a DFA to accept strings of a’s and b’s having an even number of a’s and b’s.

Module 1 & 2 2
7. Construct the regular expressions represent the following:

a)The set of all strings over {0,1}, beginning with 00.

b)The set of all strings over {0,1}, ending with 00 and beginning with 1.

8. Distinguish Kleene closure and positive closure with example.

Kleene Closure
if is a set of symbols then we use Σ∗ to denote the set of strings obtained by concatenating zero or more symbols from Σ
of any length, in general any string of any length which can have only symbols specified in Σ.
Σ

= U
i=∞
i=0
{W ∣ ∣w∣ = i}
​ using the symbols from the alphabet Σ.

Example: Σ = {a, b}
therefore, Σ* = {ε, a, ab, aba, b, aabb, abba, baba,…….aaaaaaaaaaaabbbbbbbbbbbbbbbb}

Module 1 & 2 3
Positive Closure
If Σis a set of symbols then we use Σ+ to denote the set of strings obtained by concatenating one or more symbols from
Σ  of any length, in general any string of any length which can have only symbols specified in Σ(except ε).

Σ
+
= U
i=∞
i=1
{W ∣ ∣w∣ = i}
​ using the symbols from the alphabet Σ.

Example: Σ = {a, b}
therefore,
Σ
+
 = {a, ab, aba, b, aabb, abba, baba,…….aaaaaaaaaaaabbbbbbbbbbbbbbbb}

9. What do you mean by compatibility graph?


In Theory of Computation (TOC), a compatibility graph is used to represent relationships between elements based on
their compatibility in computational problems. It is particularly relevant in areas like automata theory, formal languages,
and computational complexity.
A compatibility graph consists of:

Vertices: Representing elements such as states in an automaton or symbols in a formal language.

Edges: Connecting pairs of elements that are considered compatible based on a given computational criterion.

Example in TOC

Consider a finite automaton where certain states can be merged without affecting the language recognized by the
automaton. A compatibility graph can be constructed where:

Each state is a vertex.

An edge exists between two states if they can be merged while preserving the automaton's behavior.

This concept is useful in minimizing finite automata, where states are grouped based on their compatibility to reduce the
number of states while maintaining the same language recognition.

10. State the formal definition of Mealy machine and give a suitable example.
A Mealy Machine is a six-tuple (Q, Σ, ∆, λ, q0), where

Q is a finite set of states

Σ is the set of input alphabet

∆ is the output alphabet

λ is the output function mapping Q x Σ → ∆

q0 is the initial state

In case of mealy machine, the output symbol depends on the transition.

Example:

Present State 0 | State Output 1 | State Output

q1 

q3 

0 q2 

0

q2 
​ q1 
​ 1 q4 
​ 0

q3 
​ q2 

1 q1 

1

q4 
​ q4 

1 q3 

0

Module 1 & 2 4
11. Convert the following Moore machine to Mealy Machine.
Q a b Output

q0 q1 q0 0

q1 q1 q2 0

q2 q1 q0 1

Q a output b output

q0 q1 0 q0 0

q1 q1 0 q2 1

q2 q1 0 q0 0

12. Convert the given Moore machine into its equivalent Mealy machine.
Q a b o/p

q0 q0 q1 0

q1 q2 q0 1

q2 q1 q2 1

Q a output b output

q0 q0 0 q1 1

q1 q2 1 q0 0

q2 q1 1 q2 1

Module 1 & 2 5
Q. Illustrate a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b} such that every
accepts string starts and end with same symbol.

13. Illustrate a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b} such that every
accepts string starts and end with different symbol.

14. Illustrate a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b} such that every
accepted string W is W=SX where S=aa|bb.

Module 1 & 2 6
15. Illustrate a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b} such that every
accepted string W is W=XS where S=aa|bb.

16. Illustrate the construction of a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b}
such that every accepted string W is accepted must be like |W|=4.

17. Illustrate the construction of a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b}
such that every accepted string W is accepted must be like |W|<=4.

18. Illustrate the construction of a Minimal DFA That accepts all string over the Alphabet ∑ = {a, b}
such that every accepted string W is accepted must be like |W|>=3.

Module 1 & 2 7
19. Convert NFA to DFA
state 0 1

→q0 {q0, q1} q1

*q1 ε {q0, q1}

state 0 1

→q0 {q0, q1} q1

*{q0, q1} {q0, q1} {q0, q1}

*q1 {φ} {q0, q1}

{φ} {φ} {φ}

20. Convert the minimization of DFA

State 0 1

→q0 q1 q3

q1 q0 q3

*q3 q5 q5

*q5 q5 q5

State 0 1

→{q0, q1} {q0, q1} {q3, q5}

*{q3, q5} {q3, q5} {q3, q5}

21. Convert NFA to DFA


state 0 1

→q0 q0 q1

q1 q1, q2 q1

Module 1 & 2 8
state 0 1

*q2 q2 q1, q2

state 0 1

→q0 q0 q1

q1 {q1, q2} q1

*{q1, q2} {q1, q2} {q1, q2}

22. Construct Finite Automata which accept all strings of ∑={a, b} where W<=2.

23. Find a Moore Machine to implement the 2's complement.

24. Evaluate the minimization of the given Deterministic Finite Automaton (DFA) using the table
filling algorithm, and subsequently, illustrate the resulting equivalent DFA.

Q q0 q1 q2 q3 q4 q5

q0 Ⅹ Ⅹ Ⅹ Ⅹ Ⅹ Ⅹ

Module 1 & 2 9
Q q0 q1 q2 q3 q4 q5

q1 ✓ Ⅹ Ⅹ Ⅹ Ⅹ Ⅹ

q2 ✓ q1 q2 Ⅹ Ⅹ Ⅹ Ⅹ

q3 q0 q3 ✓ ✓ Ⅹ Ⅹ Ⅹ

q4 ✓ (q1, q4) (q2, q4) ✓ Ⅹ Ⅹ

q5 ✓ ✓ ✓ ✓ ✓ Ⅹ

(q2, q1): δ(q2, 0) → q2, δ(q1, 0) → q2, δ(q2, 1) → q5, δ(q1, 1) → q5

(q0, q3): δ(q0, 0) → q3, δ(q3, 0) → q0, δ(q0, 1) → q1, δ(q3, 1) → q4

(q1, q4): δ(q1, 0) → q2, δ(q4, 0) → q2, δ(q1, 1) → q5 δ(q4, 1) → q5,

(q2, q4): δ(q2, 0) → q2, δ(q4, 0) → q2, δ(q2, 1) → q5 δ(q4, 1) → q5,

(q0, q5): δ(q0, 0) → q3, δ(q5, 0) → q5, δ(q0, 1) → q1, δ(q5, 1) → q5, found (q1,q5)

(q3, q5): δ(q3, 0) → q0, δ(q5, 0) → q5, δ(q3, 1) → q4, δ(q5, 1) → q5

Pairs: (q0,q3), (q1,q2), (q1,q4), (q2,q4)

dead state - q5

26. Evaluate and Construct DFA accepting the set of all strings not containing 101 as a substring.

27. Summarize that there exists a DFA for every € –NFA.


Every ε-NFA (Nondeterministic Finite Automaton with epsilon transitions) has an equivalent DFA (Deterministic Finite
Automaton) that recognizes the same language. This is established through the subset construction algorithm, which
systematically converts an ε-NFA into a DFA by eliminating nondeterminism.
Key Points:

1. Elimination of ε-transitions: Convert the ε-NFA by computing the ε-closure of states.

2. Determinization using State Sets: The new DFA states represent subsets of ε-NFA states.

3. Preserving Language Recognition: The DFA accepts the same language as the original ε-NFA but is structured
deterministically.

Thus, for every ε-NFA, we can construct an equivalent DFA, ensuring that deterministic automata can represent all regular
languages.

Module 1 & 2 10
28. Justify the applications of DFA.
Deterministic Finite Automata (DFA) plays a crucial role in Computation particularly in recognizing and processing regular
languages. Here are its key applications:

1. Lexical Analysis in Compiler Design – DFA is used to tokenize source code, identifying keywords, operators, and
identifiers efficiently.

2. Pattern Matching in Formal Languages – DFA helps in recognizing specific patterns in strings, essential for text
processing and search algorithms.

3. Regular Expression Processing – DFA is used to implement regular expressions, ensuring efficient string matching in
programming and data retrieval.

4. Finite State Machine Modeling – DFA is applied in designing control systems, vending machines, and protocol
verification in networking.

5. Automata-Based Verification – DFA is used in formal verification of software and hardware systems to ensure
correctness in execution.

These applications highlight DFA’s significance computer science, making it a fundamental concept in computational
theory and practical implementations.

29. Construct Finite Automata which accept all strings of 0’s and 1’s in which both the number of
0’s and 1’s are even.

31. Evaluate an NFA which accepts strings of a's and b's starting with ab.

32. Explain Difference between Mealy and Moore machine.


Aspect Moore Machine Mealy Machine

Response to Null Produces an output corresponding


Does not produce any output
Input to the initial state

Output length for Generates an output string of length


Generates an output string of length n
input of length n n+1

Module 1 & 2 11
Aspect Moore Machine Mealy Machine

The initial output is determined by No initial output until an input is


Initial Output
the initial state provided

Output
Output is synchronized with the input;
synchronization Output is one step behind the input
changes immediately with input
with input

Suitable for applications where Ideal for applications requiring


Typical use cases
output is necessary immediate response to input changes

33. Evaluate a mealy machine for addition of two binary number.

34. Evaluate a Finite Acceptor that accepts set of strings where the number of 0'S in every string
is multiple of three over alphabet {0,1}.

35. Evaluate a Finite Acceptor that accepts all the string over {0,1} except those containing the
Substrings 001.

39. Convert the following NFA to the equivalent DFA by using ε-closure operation.

Module 1 & 2 12
NFA State DFA State a b

{0, 1, 2, 4, 7} A B C

{1, 2, 3, 4, 6, 7, 8} B B C

{1, 2, 4, 5, 6, 7} C B C

A = ε-closure of ({0}) = {0, 1, 2, 4, 7}

B = ε-closure of ({3,8}) = {1, 2, 3, 4, 6, 7, 8}

C = ε-closure of ({5}) = {1, 2, 4, 5, 6, 7}

Set 2
1. Demonstrate the DFA which is accepting the following language over the alphabet{0,1}.The set
of all the strings beginning with a1 that when interrupted as a binary integer , is multiple of 5, For
example strings101,1010and 1111 are in the language and the strings 0,100 ,111 are not.
Q 0 1

→q0* q0 q1

q1 q2 q3

q2 q4 q0

q3 q1 q2

q4 q3 q4

Module 1 & 2 13
2. Summarize the applications of automata theory.
Automata theory is fundamental in Theory of Computation (TOC), providing models for recognizing and processing formal
languages. Its key applications include:

Lexical Analysis in Compilers – Finite Automata (FA) are used to tokenize source code, identifying keywords and
operators.

Regular Expression Matching – FA helps in searching and pattern recognition in text processing.

Syntax Analysis – Pushdown Automata (PDA) assist in parsing programming languages, handling nested structures.

Formal Verification – Automata models verify correctness in software and hardware systems.

Artificial Intelligence & NLP – Automata aid in speech recognition and natural language processing.

Network Protocol Design – DFA models communication protocols like TCP/IP.

Game Theory & Decision Making – Automata help model strategic interactions and automated decision-making.

3. Convert the following NFA to DFA.

NFA State DFA state a b

*→{q0, q1} A B φ

*{q0, q1, q2} B B B

A = ε-closure of {q0} = {q0 q1}

B = ε-closure of {q0, q2} = {q0, q1, q2}

Module 1 & 2 14
4. Convert the following NFA with ε moves to DFA without ε moves.

5. Design a Mealy Machine that detects the sequence "1010", producing an output '1' when
detected, including overlapping occurrences, and '0' otherwise. Provide the state transition table
and state diagram.

6. Convert the following NFA to its equivalent DFA.

NFA Q 0 1

→p {p, q} {p}

q {r} {r}

r {s} {φ}

*s {s} {s}c

Module 1 & 2 15
DFA Q 0 1

→p pq p

pq pqr pr

pqr pqrs pr

pr pqs p

*pqrs pqrs prs

*pqs pqrs prs

*prs pqs ps

*ps pqs ps

7. Identify whether the two DFAs are equivalent or not.

States c equivalence d equivalent

q0 q3 q0 q3 yes q1 q4 yes

q1 q4 q2 q6 yes q0 q5 no

→ M and M’ is not equivalent

8. Minimize and simplify the following DFA using Myhill-Nerode theorem

Q a b

→q0 q1 q2

q1 q1 q3

q2 q1 q2

q3 q1 q4

*q4 q1 q2

Module 1 & 2 16
Module 1 & 2 17

You might also like