0% found this document useful (0 votes)
2 views

Theory of computation2

The document provides a comprehensive overview of automata theory, including definitions, types of automata (DFA, NFA, E-NFA), and their applications in various fields such as compiler design and digital circuit design. It also covers formal and informal languages, the Chomsky hierarchy, and key concepts like alphabets, strings, and the Kleene star. Additionally, it includes detailed examples of designing deterministic finite automata (DFA) for specific patterns and conditions.

Uploaded by

balakhatun215
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Theory of computation2

The document provides a comprehensive overview of automata theory, including definitions, types of automata (DFA, NFA, E-NFA), and their applications in various fields such as compiler design and digital circuit design. It also covers formal and informal languages, the Chomsky hierarchy, and key concepts like alphabets, strings, and the Kleene star. Additionally, it includes detailed examples of designing deterministic finite automata (DFA) for specific patterns and conditions.

Uploaded by

balakhatun215
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Table of Contents

Introduction to Automata ...........................................................................................3


Automata .................................................................................................................3
Abstract Machine ....................................................................................................3
Theory of Automata ................................................................................................3
Formal and Informal Languages ................................................................................4
Application of Theory of Automata and Formal Languages .....................................4
Chomsky Hierarchy (Chomsky Classification of Languages) ..................................6
Key Concepts in Automata Theory ............................................................................6
Finite Automata ..........................................................................................................7
Deterministic Finite Automaton (DFA) .....................................................................9
Regular Expressions .................................................................................................17
Non-Deterministic Finite Automaton (NFA): ..........................................................19
Conversion of NFA to DFA: .................................................................................22
Epsilon Non-Deterministic Finite Automaton (E-NFA) ..........................................26
Conversion of E-NFA to NFA...............................................................................27
Minimization of DFA ...............................................................................................30
Alternative Method of Minimization of DFA .......................................................35
Finite Automata with Output ...................................................................................36
Moore Machine .....................................................................................................36
Mealy Machine .....................................................................................................39
Arden's Method ........................................................................................................41
Pumping lemma: - ....................................................................................................43
Introduction to Automata
• Automata is the plural of Automaton.
• Automata are mathematical models or abstract machines that represent computational
systems.
• An automaton is a self-operating machine.
• These models are designed to simulate the behavior of real machines that process a series
of inputs to produce outputs.

Automata
An automaton is a computational model with the following components:

1. States: Represent different conditions or configurations the automaton can be in.


2. Transitions: Rules that dictate how the automaton moves from one state to
another based on an input symbol.
3. Input Symbols: The alphabet that an automaton can process.
4. Start State: The state where the automaton begins its computation.
5. Final State: Specific states that indicate successful processing of an input

Abstract Machine
• An abstract machine is a theoretical design used to simulate the logic and
behavior of computational processes.
• It does not have physical components.
• It consists of defined states, transitions, and rules that represent and solve
problems by processing inputs step by step.
• Examples:
o Finite Automaton: Used for pattern recognition.
o Turing Machine: Used for performing complex computations.

Theory of Automata
• The Theory of Automata is a branch of computer science that deals with the
design and analysis of abstract machines and the problems they can solve.
• It is foundational for understanding how computers process information,
recognize patterns, and perform computations.
Formal and Informal Languages
In the theory of computation, languages define sets of rules for creating valid strings of symbols.
Here’s the distinction between formal and informal languages:

1. Formal Languages

• A formal language is a set of strings formed from a specific alphabet that follow
well-defined rules.
• Characteristics:
o Created using a specific set of symbols.
o Follows structured and precise rules.
o Not used for human communication but rather as a "game of symbols"
with formal rules.
• Applications:
o Programming languages (e.g., Python, Java).
o Mathematical formulas.

2. Informal Languages

• Informal languages, also called natural languages, are used for everyday
communication (e.g., English, Urdu, Spanish).
• Characteristics:
o Lack strict rules and can be flexible in meaning.
o Open to interpretation, making them unsuitable for precise computations
and programming.
• Summary: Informal languages are flexible and widely used by humans for general
communication.

Application of Theory of Automata and Formal Languages


The theory of automata has applications in various fields, including:

1. Foundation of formal Languages:


• Automata theory forms the basis for formal languages, which are essential
for designing and implementing modern programming languages.

2. Machine Communication:
• Automata and formal languages enable effective communication between
machines and humans.
• This concept is fundamental for the functioning of computing applications.

3. Compiler Design:
• Compilers, which convert high-level programming code into machine code,
rely heavily on automata theory principles.
• Automata assist in:
o Breaking code into smaller parts.
o Checking if the code follows the correct syntax.
o Identifying and highlighting errors in the code.

4. Text searching and pattern matching:


• Automata aid in text search and pattern matching, such as:
o Searching for words in documents (e.g., text editors).
o Finding specific patterns in large datasets (e.g., DNA sequences).

5. Digital Circuit Design and Artificial Intelligence


• Automata concepts are used in:
o Analyzing and designing digital circuits.
o Computational biology and artificial intelligence (AI) to develop
logical models and algorithms.
o Designing parts of computer processors for task control.

6. Internet and Network Protocols


• Automata verify rules in network communication to ensure data is sent
correctly.
• They detect unusual network patterns, such as hacker activities.

7. System Verification
• Automata theory helps prove the correctness of programs by providing a
structured way to verify program behavior.
• This is especially important for reliable systems, such as those used in
aviation or medical devices.

8. Video Game Design:


• Finite state automata are used in video game design, particularly for
controlling game states and character actions.
Chomsky Hierarchy (Chomsky Classification of Languages)
• The Chomsky hierarchy, introduced by Noam Chomsky in 1956, classifies
languages based on the complexity of the rules (grammar) that define them.
Chomsky Hierarchy Table:

S. No. Type Grammar Automaton


1 Type 3 Regular FA, DFA, NFA
2 Type 2 Context-Free Grammar Pushdown Automaton (PDA)
3 Type 1 Context-Sensitive Grammar Linear-Bounded Automaton (LBA)
4 Type 0 Unrestricted Turing Machine

Applications of Chomsky Hierarchy:

• Type 3:
o Pattern matching, text search algorithms, and lexical analysis.
• Type 2:
o Syntax analysis in compilers, XML, HTML, and artificial intelligence.
• Type 1:
o Natural language processing, formal verification, and programming
languages.
• Type 0:
o Theoretical computing and problem solvability analysis.

Key Concepts in Automata Theory


Several key concepts are essential in describing languages and their structure:

1. Alphabets (Σ)

• Definition: A finite set of symbols or characters.


• Notation: Denoted by the Greek letter Σ (sigma), e.g., Σ = {a, b}.
• Role:
o Defines the vocabulary of formal languages.
o Symbols in an alphabet can include letters, digits, or other characters

2. Strings (ω)

• Definition: A finite sequence of symbols from a given alphabet.


• Strings can be of any length, including empty strings.
• Notation: Denoted as ω ∈ Σ*.
• Examples:
o For Σ = {a, b}, strings can include ‘a’, ‘b’, ‘ab’, etc.

Length of String:

• The length of a string refers to the number of symbols in the string.


• Notation: Denoted as |S|.
• Examples:
o If S = "Abcde", then |S| = 6.
o If S is empty (denoted by ε or λ), then |S| = 0.

3. Kleene Star (Σ*):

• Definition: An operation that generates a set of all possible strings (including the
empty string) by concatenating zero or more symbols from an alphabet.
• Notation: Denoted by Σ*.
• Examples:
o For Σ = {a, b}, Σ* includes {ε, a, b, aa, bb, ab, …}.

4. Kleene Closure/Plus (Σ+):

• Definition: Similar to the Kleene star, but it does not include the empty string.
• Notation: Denoted by Σ+.
• Examples:
o For Σ = {a, b}, Σ+ includes {a, b, aa, bb, ab, …}.

5. Language

• Definition: A set of strings formed using an alphabet.


• Example:
o For Σ = {a, b}, a language L of length 2 is:
▪ L = {aa, ab, bb, ba}.

Finite Automata
• Definition:
A finite automaton is a theoretical computational model used to recognize and process
strings of symbols.
• Working Principle:
o A finite automaton processes strings of symbols from an alphabet, transitioning
between states according to a transition function.
o A string is accepted if, after processing all symbols, the automaton ends in an
accept state.
• Applications:
o Pattern matching.
o Network protocols.
o Lexical analysis (the first phase of a compiler that processes source code).
• Finite automata may either:
o Produce an output.
o Accept or reject a string.

Types of Finite Automata:

1. Without output:

1. DFA (Deterministic Finite Automaton):


o For each state and input, there is a unique next state.
2. NFA (Nondeterministic Finite Automaton):
o For a state and input, multiple transitions are possible.
3. Epsilon-NFA (E-NFA):
o Allows transitions without consuming an input symbol (epsilon
transitions).

2. With output:

• Mealy Machine:
o Produces output based on the current state and input.
• Moore Machine:
o Produces output based only on the current state.
Deterministic Finite Automaton (DFA)
• Definition:
A deterministic finite automaton (DFA) is a finite state machine that either accepts
or rejects strings of symbols.
Alternatively, a DFA can be defined as a finite state machine that recognizes patterns
in strings.
Characteristics of DFA
1. Deterministic:
o Each state has exactly one transition for each symbol in the alphabet,
ensuring a unique path for any input string.
2. Finite State:
o A DFA has a finite number of states, including:
▪ One start state.
▪ One or more final (accepting) states.

Formal Definition of DFA


A DFA can be formally defined by a 5-tuple:
DFA = (Ɵ, ∑, q₀, F, δ), where:
1. States (Ɵ):
o A finite set of states that is not empty.
2. Alphabet (∑):
o A finite set of input symbols.
3. Transition Function (δ):
o A function that defines state transitions.
o Notation: δ: Ɵ × ∑ → Ɵ.
4. Start State (q₀):
o The state where the DFA begins processing the input string.
5. Final States (F):
o A subset of Ɵ that defines the accepting (final) states.
Example of a DFA
Problem:
Design a DFA that accepts strings ending with 01 over the alphabet ∑ = {0, 1}.
Solution:
1. States:
o q₀: Start state.
o q₁: Intermediate state after reading 0.
o q₂: Final state after reading 01.
o Ɵ = {q₀, q₁, q₂}.
2. Transition Function (δ):
Define transitions based on the input symbols (0 or 1):
o δ (q₀, 0) → q₁
o δ (q₀, 1) → q₀
o δ (q₁, 0) → q₁
o δ (q₁, 1) → q₂
o δ (q₂, 0) → q₁
o δ (q₂, 1) → q₀
3. Start State:
o q₀.
4. Final State:
o q₂ (accepts strings ending with 01).
Diagram Representation:
Constructing a DFA
Steps to Construct a DFA:

1. Define the Language:


o Clearly specify the language that the DFA should recognize.
o Example: A DFA that accepts strings ending with 01.
2. Identify States:
o Determine the necessary states for the DFA.
o Each state represents a unique configuration of the automaton as it
processes the input string.
o Example:
▪ q₀: The start state where no input has been processed yet.
▪ q₁: A state reached after processing the first alphabet (e.g., 0).
▪ q₂: The final (accepting) state where the input string ends with the
desired pattern (e.g., 01).
3. Define Transitions:
o Specify how the DFA moves from one state to another based on the input
symbols.
o This is governed by the transition function (δ).
4. Identify Start and Accept States:
o Start State: The state where the DFA begins processing the input
symbols.
o Final States: These states indicate successful acceptance of a string in the
language.
5. Draw the Transition State Diagram:
o Visualize the DFA with a state transition diagram.
o Represent each state with a circle:
▪ A single arrow (→) pointing to a state represents the initial state.
▪ Arrows (→) between states represent transitions based on input
symbols.
▪ A double circle represents the final (accepting) state.

Examples of DFA Designs:

i. Design a DFA to Accept Strings "101" Where ∑ = {0, 1}:

• States: q₀, q₁, q₂, q₃ (final state).


• Diagram representation.
ii. Design a DFA That Accepts All Strings Starting with Zero, Where ∑ = {0, 1}:

Input Output
100 Reject
01000 Accept
10101 Reject
0101110 Accept
0000 Accept

iii. DFA for Strings Starting with '1' and ending with '0' (∑ = {0, 1}):

Input Output
1010 Accept
0001 Reject
10110 Accept
0101 Reject
0111 Reject

v. DFA Accepting Strings Starting and Ending with Different Symbols (∑ = {0, 1}):

Input Output
aaa Reject
aaababbab Accept
abababa Reject
bababa Accept
baaaab Reject

v. DFA Accepting All Strings (∑ = {0, 1}):


Input Output
01011 Accept
100011 Accept
11101 Accept
1010101 Accept
100000 Accept

vi. DFA Accepting Even Number of 0’s and Even Number of 1’s (∑ = {0, 1}):

Input Output
0011 Accept
0111 Reject
11001100 Accept
101010 Reject
10000 Reject

vii. DFA Accepting Strings Ending with "00" (∑ = {0, 1}):

Input Output
10000 Accept
100101 Reject
1100 Accept
111110 Reject
011100 Accept

viii. DFA Accepting Strings with Total Number of ‘a’s Divisible by 3 (∑ = {a, b}):

Input Output
baba Reject
aaa Accept
bbbba Reject
bbbbbb Accept
aabab Reject
ix. DFA Accepting Exactly One 'a' Over ∑ = {a, b}:
Input Output
aab Reject
a Accept
bbbba Reject
abab Reject
abaa Reject

x. DFA Accepting Exactly One 'a' or 'b' Over ∑ = {a, b}:

Input Output
a Accept
abbbba Reject
baba Reject
b Accept
baaaa Reject

xi. DFA for Strings with 'b' as the Second Letter (∑ = {a, b}):

Input Output
abaaba Accept
aaabaa Reject
abbbbb Accept
aaaaa Reject

xii. DFA Accepting Strings with Exactly Four '1’s (∑ = {0, 1}):

Input Output
01111001 Reject
1111 Accept
001111 Accept
01010101 Accept
10001 Reject
xiii. DFA Accepting Only One 'a' Per String (∑ = {a, b}):

Input Output
abbb Accept
abbbaa Reject
bbbba Accept
bbb Reject
abab Reject

xiv. DFA for Strings Containing '00' (∑ = {0, 1}):


Input Output
01 Reject
1100 Accept
0101 Accept
111 Reject
0111 Reject

xv. DFA for Strings Ending with "ab" (∑ = {a, b}):

Input Output
ab Accept
aaba Reject
ababaa Reject
aaaabbab Accept
bbaa Reject

xvi. DFA for Binary Numbers Divisible by 2 (∑ = {0, 1}):

Input Output
00 Accept
10 Accept
11 Reject
100 Accept
xvii. DFA for Strings Starting with "aba" (∑ = {a, b}):

Input Output
aba Accept
abba Reject
baab Reject
abab Accept
baba Reject

xviii. DFA for Strings of Length Exactly 2 (∑ = {0, 1}):

Input Output
0111 Reject
11 Accept
00 Accept
01101 Reject
010 Reject

xix. DFA for Strings Without "00" or "11" as Substrings (∑ = {0, 1}):

Input Output
11 Reject
00 Reject
1010 Accept
1100 Reject
010111 Reject

xx. DFA for Strings Starting and Ending with 0 (∑ = {0, 1}):

Input Output
0011 Reject
01110 Accept
1000 Reject
011101 Reject
011110 Accept
xxi. DFA for Strings Where Each '0' Is Surrounded by '1's (∑ = {0, 1}):

Input Output
1 Accept
101 Accept
111 Accept
100 Reject
10 Reject

xxii. DFA for Strings of Length ≤ 2 (∑ = {0, 1}):

Input Output
100 Reject
11 Accept
10 Accept
11101 Reject
0 Accept

Regular Expressions
Definition:

A regular expression (regex) is a sequence of characters that define a search pattern. It


is used for:

• Matching strings
• Validating input
• Searching/manipulating text based on specific rules

Basic Components of Regular Expressions

1. Literals:
A literal matches exact characters in a string.
Example: The literal "a" matches the character "a" wherever it appears in a
string.
2. Concatenation:
Concatenation represents a sequence of characters that must appear in order.
Example: The expression "abc" matches the substring "abc" in the string.
3. Alternation:
Alternation is represented by the pipe symbol (|), which denotes a choice
between alternatives.
Example: "a|b" matches either "a" or "b" in a string.
4. Kleene Star:
The Kleene star operator (*) matches zero or more occurrences of the preceding
character or group.
Example: "a*" matches "" (empty string), "a", "aa", and so on.
5. Kleene Plus:
The Kleene plus operator (+) matches one or more occurrences of the preceding
character or group.
Example: "a+" match "a", "aa", "aaa", but not "".
6. Optional:
The question mark (?) makes the preceding character or group optional, meaning
it can occur zero or one time.
Example: "a?" matches "" (empty string) or "a".
7. Character Class:
A character class allows matching any one character listed inside square brackets
([]).
Example: [abc] matches "a", "b", or "c".
8. Range:
A range specifies a span of characters inside square brackets ([]).
Example: [a-z] matches any lowercase alphabetic character from "a" to "z".
9. Anchors:
Anchors are special characters used to match positions in a string, rather than
actual characters.
Example:
o ^a matches any string that starts with "a".
o a$ matches any string that ends with "a".
10. Groups:
Parentheses (()) group expressions, treating them as a single unit. They are also
used to apply operators like * or + to the entire group.
Example: (ab)+ matches "ab", "abab", "ababab", and so on.

Examples:

1. Design a regular expression for the language accepting all strings of a’s over ∑ =
[a].
Solution: R.E = (a)*
2. Design a regular expression for the language accepting all strings of a’s except
null string over ∑ = [a].
Solution: R.E = (𝑎+ )
3. Design a regular expression for language accepting all strings of a’s and b’s over
∑ = [a, b].
Solution: R.E = (a+b) *
4. Write regular expression for language accepting all strings of a’s and b’s except
null string over ∑ = [a, b].
Solution: R.E = (𝑎 + 𝑏)+ OR R.E = (a+b). (a+b) *
5. Design regular expression for language accepting all string ending with 00 over ∑
= [0,1].
Solution: R.E = (0+1) *.00
6. Design regular expression for language which accepts string starting from 1 and
ending with 0, over ∑ = [0,1].
Solution: R.E = 1. (0+1) *.0
7. Design regular expression for language accepting strings start and end with a over
∑ = [a, b].
Solution: R.E = a.(a+b) *. a
8. Design regular expression for language in which any number of a’s is followed by
any number of b’s is followed by any number of c’s where ∑ = [a, b, c].
Solution: R.E = abc*
9. Design regular expression for language accepting strings start with a and end with
any symbol where ∑ = [a, b].
Solution: R.E = a.(a+b) *
10. Design regular expression for language accepting strings that start and end with
any combination of a’s and b’s but the 2nd symbol will be “b” where ∑ = [a, b].
Solution: R.E = (a+b). b.(a+b) *
11. Design regular expression which accepts strings in which there will be 4 “1’s”
and any of “0’s” where ∑ = [0,1].
Solution: R.E = 10101010
12. Design regular expression for language accepting strings starting and ending with
a and any combination of ‘b’ in between where ∑ = [a, b].
Solution: R.E = a b*a
13. Design regular expression for language accepting string having only one “a”
where ∑ = [a].
Solution: R.E = a
14. Design regular expression for language accepting string having only one ‘a’ or ‘b’
where ∑ = [a, b].
Solution: R.E = (a+b)
15. Design R.E accepting strings having only one ‘a’ where ∑ = [a, b].
Solution: R.E = bab

Non-Deterministic Finite Automaton (NFA):


Definition:
NFA is a type of finite state machine used in the theory of computation, similar to DFA.
However, an NFA allows multiple possible transitions from the same input from a given
state. In other words, an NFA has multiple possible input symbols from a current state to
the next.

Formal Definition of NFA:

An NFA can be formally defined by 5-tuples:


N = (θ, ∑, q₀, F, δ)
Where:

• θ (states): A finite set of states.


• ∑ (alphabet): A finite set of input symbols (alphabet).
• δ (transition): The transition function i.e. δ: Ɵ × ∑ → Ɵ.
• q₀ (start state): The start state.
• F (final states): A set of accept states.

Examples:
1. Design NFA that accepts all strings ending with ‘a’, where ∑ = [a, b].
Solution: R.E = (a+b) *. a

Input Output
ab Reject
aaa Accept
aba Accept
bbaab Reject

2. Design NFA which accepts all strings ending with “00”, where ∑ = [0,1].
Solution:
Input Output
11100 Accept
101001 Reject
1000 Accept
00011 Reject
3. Design NFA which accepts all strings containing substring “aa”, where ∑ =
[a, b].
Solution: R.E = (a+b) * aa(a+b) *
Input Output
abbabb Reject
abaab Accept
abbbaab Accept
ababa Reject

4. Design the NFA transition diagram from the transition table given below.

Transition Table:

States 0 1
q₀ {q₀, q₁} {q₀, q₂}
q₁ {q₃} ε
q₂ {q₂, q₃} {q₃}
*q₃ {q₃} {q₃}

Solution:
Transition diagram can be created with states q₀, q₁, q₂, and q₃, showing the
transitions as per the table above.

5. Construct an NFA for a language L that accepts all strings in which the third
symbol from the right end is always “a”, over ∑ = {a, b}.
Solution:
The NFA will track the last three symbols to ensure the third symbol from the
right end is "a."
Characteristics of NFA:

• Multiple Transition:
From any state, an NFA can have multiple transitions for a given input
symbol.
• Epsilon (ε) Transition:
An NFA can include transitions that do not consume input symbols, known as
epsilon (ε) transitions.
• Acceptance of States:
An input string is accepted by an NFA if there exists at least one path from the
start state to an accept state.
• Non-determinism:
NFA does not follow a unique path; it can take multiple possible paths or
make multiple choices for a given input.

Conversion of NFA to DFA:


1. Given NFA:

States 0 1
→q₀ {q₀} {q₁}
q₁ {q₁, q₂} {q₁}
*q₂ {q₂} {q₁, q₂}

Solution:

To convert the given NFA to DFA, define the tuple of DFA as:
M' = (θ', ∑', q₀', F', δ')

Transition Functions:

• δ (q₀, 0) = {q₀} → δ'(q₀, 0) = {q₀}


• δ (q₀, 1) = {q₁} → δ'(q₀, 1) = {q₁}
• δ (q₁, 0) = {q₁, q₂} → δ'(q₁, 0) = {q₁, q₂}
• δ (q₁, 1) = {q₁} → δ'(q₁, 1) = {q₁}
• δ (q₂, 0) = {q₂} → δ'(q₂, 0) = {q₂}
• δ (q₂, 1) = {q₁, q₂} → δ'(q₂, 1) = {q₁, q₂}

Transition for new state [q₁, q₂]:

• δ'([q₁, q₂], 0) = {q₁, q₂} → δ'([q₁, q₂], 0) = [q₁, q₂]


• δ'([q₁, q₂], 1) = {q₁, q₂} → δ'([q₁, q₂], 1) = [q₁, q₂]

Transition Table for DFA:

States 0 1
→[q₀] [q₀] [q₁]
[q₁] [q₁, q₂] [q₁]
*[q₂] [q₂] [q₁, q₂]
[q₁, q₂] [q₁, q₂] [q₁, q₂]

2. Given NFA:

Step 1: Transition Table of NFA

States a b
→q₀ {q₀, q₁} {q₁}
*q₁ {q₂} {q₂}
q₂ {∅} {q₂}

Step 2: Transition Functions for DFA

NFA Transition DFA Transition


δ (q₀, a) = {q₀, q₁} δ'([q₀], a) = [q₀, q₁] (new state)
δ (q₀, b) = {q₁} δ'([q₀], b) = [q₁]
δ (q₁, a) = {q₂} δ'([q₁], a) = [q₂]
δ (q₁, b) = {q₂} δ'([q₁], b) = [q₂]
δ (q₂, a) = {∅} δ'([q₂], a) = [∅]
δ (q₂, b) = {q₂} δ'([q₂], b) = [q₂]

Step 3: Transition for New States

1. [q₀, q₁]:
o δ'([q₀, q₁], a) = δ (q₀, a) ∪ δ (q₁, a)
= {q₀, q₁} ∪ {q₂}
= [q₀, q₁, q₂]
o δ'([q₀, q₁], b) = δ (q₀, b) ∪ δ (q₁, b)
= {q₁} ∪ {q₂}
= [q₁, q₂]
2. [q₀, q₁, q₂]:
o δ'([q₀, q₁, q₂], a) = δ (q₀, a) ∪ δ (q₁, a) ∪ δ (q₂, a)
= {q₀, q₁} ∪ {q₂} ∪ {∅}
= [q₀, q₁, q₂]
o δ'([q₀, q₁, q₂], b) = δ (q₀, b) ∪ δ (q₁, b) ∪ δ (q₂, b)
= {q₁} ∪ {q₂} ∪ {q₂}
= [q₁, q₂]
3. [q₁, q₂]:
o δ'([q₁, q₂], a) = δ (q₁, a) ∪ δ (q₂, a)
= {q₂} ∪ {∅}
= [q₂]
o δ'([q₁, q₂], b) = δ (q₁, b) ∪ δ (q₂, b)
= {q₂} ∪ {q₂}
= [q₂]

Step 4: Transition Table for DFA

States a b
→[q₀] [q₀, q₁] [q₁]
*[q₁] [q₂] [q₂]
[q₂] [∅] [q₂]
*[q₀, q₁] [q₀, q₁, q₂] [q₁, q₂]
*[q₀, q₁, q₂] [q₀, q₁, q₂] [q₁, q₂]
*[q₁, q₂] [q₂] [q₂]

3. Given NFA state a b

→𝑞0 {𝑞0 , 𝑞1 } {𝑞1 }


*𝑞1 { 𝑞2 } { 𝑞2 }

𝑞2 {𝜙} { 𝑞2 }
▪ Let M’ = = (θ′, ∑’, q 0 ′, F’, δ′) be DFA.
▪ We will calculate the 𝛿′-transition for DFA.
NFA DFA

𝛿(𝑞0 , 𝑎)={ 𝑞0 , 𝑞1 } 𝛿 ′ [(𝑞0 , 𝑎)]= [ 𝑞0 , 𝑞1 ]


→new state
𝛿(𝑞0 , 𝑏)={ 𝑞1 } 𝛿′[(𝑞0 , 𝑏)]=[ 𝑞1 ]

𝛿(𝑞1 , 𝑎)= {𝑞2 } 𝛿′[(𝑞1 , 𝑎)]= [𝑞2 ]

𝛿(𝑞1 , 𝑏)= {𝑞2 } 𝛿 ′ [(𝑞1 , 𝑏)]= [𝑞2 ]

𝛿(𝑞2 , 𝑎) = {𝜙} 𝛿 ′ [(𝑞2 , 𝑎)] = [𝜙]

𝛿(𝑞2 , 𝑏)= {𝑞2 } 𝛿 ′ [(𝑞2 , 𝑏)]= [𝑞2 ]

• Now we will calculate 𝛿 ′ − 𝑡𝑟𝑎𝑛𝑠𝑖𝑡𝑖𝑜𝑛 for new state [ 𝑞0 , 𝑞1 ].


𝛿 ′ ([ 𝑞0 , 𝑞1 ], 𝑎) = 𝛿(𝑞0 , 𝑎)𝑈 𝛿(𝑞1 , 𝑎)
= (𝑞0 , 𝑞1 ) U (𝑞2 )
= [ 𝑞0 , 𝑞1 , 𝑞2 ]
𝛿 ′ ([ 𝑞0 , 𝑞1 ], 𝑏) =𝛿(𝑞0 , 𝑏)𝑈 𝛿(𝑞1 , 𝑏)
= [𝑞1 ] U [𝑞2 ]
=[𝑞1 , 𝑞2 ]
• Now calculate 𝛿 ′ -transition for [ 𝑞0 , 𝑞1 , 𝑞2 ]
𝛿 ′ ([ 𝑞0 , 𝑞1 , 𝑞2 ], 𝑎) = 𝛿(𝑞0 , 𝑎)𝑈𝛿(𝑞1 , 𝑎)U 𝛿(𝑞2 , 𝑎)
= ( 𝑞0 , 𝑞1 ) U (𝑞2 ) U (𝜙)
= [ 𝑞0 , 𝑞1 , 𝑞2 ]
𝛿 ′ ([ 𝑞0 , 𝑞1 , 𝑞2 ], 𝑏) = 𝛿(𝑞0 , 𝑏) U 𝛿(𝑞1 , 𝑏)U 𝛿(𝑞2 , 𝑏)
= [𝑞1 ] U [𝑞2 ] U [𝑞2 ]
=[𝑞1 , 𝑞2 ]

• Now calculate 𝛿 ′ -transition for [𝑞1 , 𝑞2 ]


𝛿 ′ ([𝑞1 , 𝑞2 ], a) = 𝛿(𝑞1 , 𝑎) U 𝛿(𝑞2 , 𝑎)
= [𝑞2 ] U [𝜙]
= [𝑞2 ]
𝛿 ′ ([𝑞1 , 𝑞2 ], b) = 𝛿(𝑞1 , 𝑏) U 𝛿(𝑞2 , 𝑏)
= [𝑞2 ] U [𝑞2 ]
=[𝑞2 ]

• The new generated state is final state because it contains a final state 𝑞1 ,so
the transition table for DFA will be:
States a b
→[𝑞0 ] [𝑞0 , 𝑞1 ] [𝑞1 ]
*[𝑞1 ] [ 𝑞2 ] [𝑞2 ]

[𝑞2 ] [𝜙] [ 𝑞2 ]

*[ 𝑞0 , 𝑞1 ] [𝑞0 , 𝑞1 , 𝑞2 ] [𝑞1 , 𝑞2 ]
*[𝑞0 , 𝑞1 , 𝑞2 ] [𝑞0 , 𝑞1 , 𝑞2 ] [𝑞1 , 𝑞2 ]
*[𝑞1 , 𝑞2 ] [𝑞2 ] [𝑞2 ]

• The transition diagram for DFA is:

Epsilon Non-Deterministic Finite Automaton (E-NFA)


Definition:

An E-NFA is an extension of a Non-Deterministic Finite Automaton (NFA) that


allows epsilon (ε) transitions. These transitions enable the automaton to move
from one state to another without consuming any input symbol.
Key Difference between E-NFA and NFA:

• In an NFA, every transition requires an input symbol.


• In an E-NFA, transitions can occur spontaneously using ε, allowing state changes
without processing any input.

Characteristics of E-NFA:

1. Multiple Paths with ε-Transitions:


o Similar to an NFA, an E-NFA can be in multiple states simultaneously
for a given input symbol.
o ε-transitions allow the automaton to explore multiple paths without
reading any symbol.
2. Accepting States:
o An E-NFA accepts a string if it can move from the start state to an
accepting state.
o This can involve any number of ε-transitions in addition to regular
input transitions.
3. Epsilon Closure:
o The set of all states reachable from a given state using only ε-
transitions (including the state itself) is called its epsilon closure.
o Epsilon closure is critical for converting E-NFA to NFA or DFA.
4. Input Processing:
o When an input symbol is processed, the E-NFA first considers all
possible ε-transitions to move to new states before reading the input.
o Example:

Conversion of E-NFA to NFA


o Converting an E-NFA to NFA involves removing ε-transitions to create an
equivalent NFA that accepts the same language.
Example:

Convert the given E-NFA to NFA.


Solution:
We begin by creating the transition table from the given transition diagram:

States 0 1 ε
→q₀ {q₁} ∅ ∅
q₁ ∅ ∅ {q₂}
*q₂ ∅ {q₂} ∅

Step 1: Calculate ε-closure for each state.

• ε-closure(q₀) = {q₀}
• ε-closure(q₁) = {q₁, q₂}
• ε-closure(q₂) = {q₂}

Step 2: Compute δ'-transitions for NFA:

1. δ'(q₀,0) = ε-closure({δ(q₀,0)})
= ε-closure({q₁})
= {q₁, q₂}
2. δ'(q₀,1) = ε-closure({δ(q₀,1)})
= ε-closure (∅)
=∅
3. δ'(q₁,0) = ε-closure({δ(q₁,0)})
= ε-closure (∅)
=∅
4. δ'(q₁,1) = ε-closure({δ(q₁,1)})
= ε-closure({q₂})
= {q₂}
5. δ'(q₂,0) = ε-closure({δ(q₂,0)})
= ε-closure (∅)
=∅
6. δ'(q₂,1) = ε-closure({δ(q₂,1)})
= ε-closure({q₂})
= {q₂}

Step 3: Transition table for NFA (δ'):

States 0 1
→q₀ {q₁, q₂} ∅
q₁ ∅ {q₂}
*q₂ ∅ {q₂}
Example 2

Convert the given E-NFA to NFA.

Solution:
Transition table for the given E-NFA:

States 0 1 2 ε
→q₀ {q₀} ∅ ∅ {q₁}
q₁ ∅ {q₁} ∅ {q₂}
*q₂ ∅ ∅ {q₂} ∅

Step 1: Calculate ε-closure for each state.

• ε-closure(q₀) = {q₀, q₁, q₂}


• ε-closure(q₁) = {q₁, q₂}
• ε-closure(q₂) = {q₂}

Step 2: Compute δ'-transitions for NFA:

1. δ'(q₀,0) = ε-closure({δ(q₀,0)})
= ε-closure({q₀})
= {q₀, q₁, q₂}
2. δ'(q₀,1) = ε-closure({δ(q₀,1)})
= ε-closure({q₁})
= {q₁, q₂}
3. δ'(q₀,2) = ε-closure({δ(q₀,2)})
= ε-closure({q₂})
= {q₂}
4. δ'(q₁,0) = ε-closure({δ(q₁,0)})
= ε-closure (∅)
=∅
5. δ'(q₁,1) = ε-closure({δ(q₁,1)})
= ε-closure({q₁})
= {q₁, q₂}
6. δ'(q₁,2) = ε-closure({δ(q₁,2)})
= ε-closure({q₂})
= {q₂}
7. δ'(q₂,0) = ε-closure({δ(q₂,0)})
= ε-closure (∅)
=∅
8. δ'(q₂,1) = ε-closure({δ(q₂,1)})
= ε-closure (∅)
=∅
9. δ'(q₂,2) = ε-closure({δ(q₂,2)})
= ε-closure({q₂})
= {q₂}

Step 3: Transition table for NFA (δ'):

States 0 1 2
→q₀ {q₀, q₁, q₂} {q₁, q₂} {q₂}
q₁ ∅ {q₁, q₂} {q₂}
*q₂ ∅ ∅ {q₂}

Transition Diagrams

Minimization of DFA
Definition:

DFA minimization is the process of reducing the number of states in a Deterministic


Finite Automaton (DFA) while preserving its language. The minimized DFA:

1. Recognizes the same language as the original DFA.


2. Has fewer or equal states compared to the original DFA.
3. Is easier to understand, more efficient to implement, and optimizes
computational resources.

Key Features of Minimized DFA

1. Higher Efficiency: Fewer states mean less complexity and faster execution.
2. Simplified Representation: Easier to visualize and work with.
3. Resource Optimization: Reduced storage and computation overhead.
Example 1:
Given DFA Transition Table

States 0 1
→A B F
B G C
*C A C
D C G
E B F
F C G
G G E
H G C

Step 1: Pairwise State Comparison

We construct a table to mark pairs of states as distinguishable (×) or equivalent


(✓). Final and non-final states are inherently distinguishable.

B ×
C × ×
D × × ×
E ✓ × × ×
F × × × ✓ 
G × × × ×  ×
H × ✓ × × × × ×
A B C D E F G

Step 2: Iterative State Pair Analysis


• Now we considered every table from the above table.
i. (G, H):
𝛿(G, 0) = G 𝛿(G,1) = E
δ(H,0) = G 𝛿(H,1) = C
As “𝛿(G,1) = E” and “𝛿(H,1) = C” so we mark (×) in (G, H) pair.
ii. (F, H):
𝛿 (F,0) = C 𝛿(F,1) = G
𝛿(H,0) = G 𝛿(H,1) = C
As (F, H) Pair are not equivalent so mark (×).
iii. (E, H):
𝛿 (E,0) = B 𝛿(E,1) = F
𝛿(H,0) = G 𝛿(H,1) = C
As (E, H) Pair are not equivalent so mark (×).
iv. (D, H):
𝛿 (D,0) = C 𝛿(D,1) = G
𝛿(H,0) = G 𝛿(H,1) = C
As (D, H) Pair are not equivalent so mark (×).
v. (C, H):
𝛿 (C,0) = A 𝛿(C,1) = C
𝛿(H,0) = G 𝛿(H,1) = C
As (D, H) Pair are not equivalent so mark (×).
vi. (B, H):
𝛿 (B,0) = G 𝛿(B,1) = C
𝛿(H,0) = G 𝛿(H,1) = C
Thus, the pair (B, H) are equivalent so mark (✓) in pair (B, H).
vii. (A, H):
𝛿 (A,0) =B 𝛿(A,1) = F
𝛿(H,0) = G 𝛿(H,1) = C
As (A, H) Pair are not equivalent so mark (×).
.
.

Step 3: Equivalent Pairs

After analysis, the equivalent pairs are:

• (A, E)
• (B, H)
• (D, F)

Step 4: Minimized DFA Transition Table


States 0 1
→A B D
B G C
*C A C
D C G
G G A
Step 5: Minimized DFA Transition Diagram

Example 2:
Given DFA Transition Table

States 0 1
→q₀ q₁ q₂
q₁ q₁ q₃
q₂ q₁ q₂
q₃ q₁ q₄
*q₄ q₁ q₂

Step 1: Pairwise State Comparison


q₁ ×
q₂ ✓ ×
q₃ × × ×
q₄ × × × ×
q₀ q₁ q₂ q₃

Step 2: Iterative State Pair Analysis


i. (q2, q3):
𝛿(q2, 0) = q1 𝛿(q2, 1) = q2
𝛿(q3,0) = q1 𝛿(q3,1) = q4
As 𝛿(q2,1) = q2 and 𝛿(q3,0) = q4 is not equivalent, hence mark
()
(q2, q3) pair.
ii. (q1, q3):
𝛿(q1, 0) = q1 𝛿(q1,1) = q3
𝛿(q3,0) = q1 𝛿(q3,1) = q4
Hence, 𝛿 (q1,1) = q3 and 𝛿(q3,1) = q4 is not equivalent so mark
()
(q1, q3) pair.
iii. (q0, q3):
𝛿(q0, 0) = q1 𝛿(q0,1) = q2
𝛿(q3,0) = q1 𝛿(q3,1) = q4
Hence, 𝛿 (q0,1) = q2 and 𝛿(q3,1) = q4 is not equivalent so mark
()
(q0, q3) pair.
iv. (q1, q2):
𝛿(q1, 0) = q1 𝛿(q1,1) = q3
𝛿(q2,0) = q1 𝛿(q2,1) = q2
Hence, 𝛿 (q1,1) = q3 and 𝛿(q2,1) = q2 is not equivalent so mark
()
(q1, q2) pair.
v. (q0, q2):
𝛿(q0, 0) = q1 𝛿(q0,1) = q2
𝛿(q2,0) = q1 𝛿(q2,1) = q2
Hence, (q0, q2) pair is equivalent so mark (✓).
(q0, q2) pair.
vi. (q0, q1):
𝛿(q0, 0) = q1 𝛿(q0,1) = q2
𝛿(q1,0) = q1 𝛿(q1,1) = q3
Hence, 𝛿 (q0,1) = q3 and 𝛿(q1,1) = q4 is not equivalent so mark
() (q0, q1) pair.

Step 3: Equivalent Pairs

The equivalent pair is (q0, q2).

Step 4: Minimized DFA Transition Table


States 0 1
→q₀ q₁ q₀
q₁ q₁ q₃
q₃ q₁ q₄
*q₄ q₁ q₀
Step 5: Minimized DFA Transition Diagram

Alternative Method of Minimization of DFA


Problem:
Minimize the given DFA.

Solution:
First, draw the transition table.

States 0 1
A B C
B B D
C B C
D B E
*E B C

Step 1: Separate Non-final and Final States

• 0-equivalence: {A, B, C, D}, {E}


• 1-equivalence: {A, B, C}, {D}, {E}
• 2-equivalence: {A, C}, {B}, {D}, {E}
• 3-equivalence: {A, C}, {B}, {D}, {E}
Step 2: Minimized DFA

The minimized DFA is:

States 0 1
AC B C
B B D
D B E
E B C

Finite Automata with Output


Finite automata with output are automata where each input string produces a
corresponding output. These automata are divided into two main types based on how
input is generated:

Moore Machine
Definition:
A Moore machine is a finite state machine in which the next state is decided by
the current input symbol. The output symbol at a given time depends only on the
present state of the machine.

A Moore machine is represented by the 6-tuple (Q, q0, ∑, Δ, δ, λ), where:

• Q: Finite set of states.


• q0: Initial state of the machine.
• ∑: Finite set of input symbols.
• Δ: Output alphabet.
• δ: Transition function.
• λ: Output function.

Example 1: Design a Moore Machine

Solution:
The transition diagram and transition table are as follows:
States next state output

0 1
q0 q1 q2 1
q1 q2 q1 1

q2 q2 q0 0

Example 2: Design a Moore Machine to Generate the 1's Complement of a


Binary Number

Solution:
To generate the 1's complement of a binary number, the logic is simple: if the
input is 0, the output is 1, and if the input is 1, the output is 0.

Thus, the Moore machine requires 3 states:

1. Start state.
2. State that takes 0 and produces an output of 1.
3. State that takes 1 and produces an output of 0.

The Moore machine and transition table will be:

States Next state output


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

Example with Input 1011:

Input 1 0 1 1
States q0 q2 q1 q2 q2
output 0 0 1 0 0

Thus, 1011 → 0100.


Example 3: Design a Moore Machine for a Binary Input Sequence such that
if it has a substring 101 the machine output A, if input has substring 110 it
output B otherwise it output C.

Solution:
For designing such a machine, we need to check two conditions: the substrings "101"
and "110."

• If the string contains "101," the output will be A.


• If the string contains "110," the output will be B.
• Otherwise, the output will be C.

Example 4: Moore Machine to Determine Odd or Even Number of 1's

Solution:
We need a Moore machine to determine if an input string contains an odd or even
number of 1's. If there is an even number of 1's in the string, the output will be 1;
otherwise, it will be 0.

• q0 accepts an even number of 1's.


• q1accepts an odd number of 1's.
• There is no restriction on the number of zeros.

Example 5: design a Moore machine with the input alphabet {0,1} and
output alphabet contain {Y/N}, if the sequence contains 1010 the output will
be Y otherwise it produces N as output.
Solution:
Mealy Machine
Definition:
A Mealy machine is a machine in which the output depends upon the present input
symbol and the present state of the machine. The Mealy machine is represented by the 6-
tuple (Q, q0, ∑, Δ, δ, λ), where:

• Q: Finite set of states.


• q0: Initial state of the machine.
• ∑: Finite set of input symbols.
• Δ: Output alphabet.
• δ: Transition function.
• λ: Output function.

In a Mealy machine, the output is represented with each input symbol for each state
separated by "/".

Example 1: Design a Mealy Machine to Produce 1's Complement


Solution:
To design a Mealy machine that produces the 1's complement, the input symbols
are ∑ = {0, 1} and the output symbols are Δ = {0, 1}.
Input Output
1 0
0 1
Example 2: Mealy Machine to Print "a" When Sequence "01" is Encountered

Solution:
For this Mealy machine, the input alphabet is ∑ = {0, 1} and the output alphabet is
Δ = {a, b}.

Example 3: Mealy Machine for Binary Sequence that Generates Output


Based on Terminating Sequence

Solution:
This Mealy machine scans a sequence of input 0 and 1 and generates:

• Output A if the input string terminates with "00".


• Output B if the input string terminates with "11".
• Otherwise, it generates output C.

For this, the input alphabet is ∑ = {0, 1} and the output alphabet is Δ = {A, B, C}.
Arden's Method
Arden's Theorem is a fundamental concept in the theory of computation, used to find a
regular expression that represents the language accepted by a given DFA (Deterministic
Finite Automaton) or NFA (Nondeterministic Finite Automaton). It is applied to
construct regular expressions from a DFA or NFA.

Statement of Arden's Theorem:


Arden's theorem states that for a regular expression equation of the form:

R=Q+RP

where Q and P are regular expressions and P does not contain the empty string
(ε), the solution is:

R = QP*

Components of Arden's Theorem:

• R: The unknown regular expression (left-hand side).


• Q: A regular expression representing transitions that are not dependent on recursion
(base value).
• P: A regular expression representing transitions with recursion (loop).

Examples:
a) Construct regular expression from the given DFA.

• Solution: First, we make equation from the above DFA.


• q1 = q1a + 𝜀 → 1
• q2 = q1b + q2b → 2
• q3 is dead state.
Now considered equation 1
q1 = q1a + 𝜀
OR
q1 = 𝜀 +q1a
• apply Adren’s equation
R = Q +RP here R =q1, Q = 𝜀 , P =a
1→ q1 = 𝜀.a*
OR
q1 = a*
• Now put q1 value in equ→2
2→ q2 = a*b + q2b
q2 = a*b. b
q2 = a*. b. b* : b. b* = 𝑏 +
q2 = a*𝑏 + →Ans

b) Construct Regular expression from given DFA.

• Solution:
• First, we make equation from given DFA.
𝑞1 = 𝑞1 0 + 𝜀 → 1
𝑞2 = 𝑞1 1 + 𝑞2 1 → 2
𝑞3 = 𝑞2 0 + 𝑞3 (0+1) → 3
• Now considered equ →1
1→ 𝑞1 = 𝑞1 0 +𝜀
𝑞1 = 𝜀 + 𝑞1 0
𝑞1 =𝜀 + 0*
𝑞1 =0*→3
• Now put the value of 𝑞1 in equ 2
2→𝑞2 = 0*.1 +𝑞2 .1
𝑞2 = 0*1. 1
𝑞2 = 0*.1+ →4
• Combine the values of 𝑞1 and 𝑞2
R.E = 0* +0*.1+

c) Construct regular expression from given DFA.


• Solution: First, we make the equation:
𝑞1 =𝑞2 1 +𝑞3 0+𝜀 →1
𝑞2 = 𝑞1 0 →2
𝑞3 =𝑞1 1→3
• Now considered equ 1
1→𝑞1 = 𝜀 + 𝑞2 1 +𝑞3 0
• Now put the values of 𝑞1 and 𝑞2 in equ→1
1➔𝑞1 = (𝑞1 0).1 + (𝑞1 1).0 +𝜀
𝑞1 =𝜀 +(𝑞1 0).1 + (𝑞1 1).0
𝑞1 =𝜀 + 𝑞1 (0.1+1.0)
𝑞1 =𝜀 +(0.1+1.0) *
𝑞1 = (0.1 +1.0) *

Pumping lemma: -
Purpose:
• The pumping lemma is used to prove that a language is not regular.
However, it cannot prove that a language is regular.
• If A is a regular language, then A has a pumping length P, such that
any string s , where ∣s∣≥P, can be divided into three parts s=xyz, such
that the following conditions are satisfied:
i. x𝑦 𝑖 z 𝜀 A for every i >=0
ii. |y| > 0
iii. |xy| <=p
Examples:
1. Using pumping lemma prove that the language A= {𝑎𝑛 𝑏 𝑛 |n>=0}
is not regular.
• Sol: Assume that A is regular.
then pumping length= n
• now take string S from A i.e S = 𝑎𝑛 𝑏 𝑛 let n= 4
then S = 𝑎4 𝑏 4 = aaaabbbb
• now divide the above string into x, y and z.
aaa = x
abb =y
bb = z
• now check the condition (x𝑦 𝑖 z)
let i = 2
x 𝑦 2 z = aaa abbabb bb
= 𝑎4 𝑏 6 is not belong to A

2. Prove that W= { 𝑎𝑛 𝑏 2𝑛 |n>=0} is not regular.


• Sol: let’s W is regular
• N = pumping length
• S = aabbbb
• Let’s aa = x, bbb = y and b = z
• Condition:
x𝑦 𝑖 z → let i = 3
x𝑦 3 z →aabbbbbbbbbb is not belong to W.
Remarks and Feedback:

“If you come across any errors, unclear explanations or area that
require further clarification these notes, please do not hesitate to
reach out to me via email [[email protected]]. I would be
happy to assist and address my concerns.”

You might also like