0% found this document useful (0 votes)
3 views149 pages

Theory of Computation: Dr. Nagashree N Associate Professor and HOD, Dept of Data Science SVIT, Bangalore

The document discusses the Theory of Computation, focusing on finite automata as mathematical models for pattern recognition in data. It outlines the structure, types, and practical applications of finite automata, including deterministic (DFA) and nondeterministic (NFA) variants, and illustrates concepts through a narrative about a traveler navigating paths based on specific rules. Additionally, it presents design problems for creating DFAs based on various string conditions.

Uploaded by

surabhik021
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)
3 views149 pages

Theory of Computation: Dr. Nagashree N Associate Professor and HOD, Dept of Data Science SVIT, Bangalore

The document discusses the Theory of Computation, focusing on finite automata as mathematical models for pattern recognition in data. It outlines the structure, types, and practical applications of finite automata, including deterministic (DFA) and nondeterministic (NFA) variants, and illustrates concepts through a narrative about a traveler navigating paths based on specific rules. Additionally, it presents design problems for creating DFAs based on various string conditions.

Uploaded by

surabhik021
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/ 149

Theory of Computation

Dr. Nagashree N
Associate professor and HOD, Dept of Data Science
SVIT, Bangalore
Applications of TOC
Tic-Tac-Toe Game
Introduction to Finite
Automata
Finite automata are mathematical models of computation that can be used to
recognize patterns in data. They are essential tools in computer science,
especially in areas like compiler design and formal verification.

preencoded.png
preencoded.png
MODEL A TRAFFIC LIGHT and A TOLL BOOTH

preencoded.png
Structural Representation
States Transitions
A finite automaton has a finite The transitions between states
number of states, representing are determined by the input
different stages of processing. symbols.

Start State Accept States


The automaton begins in a Certain states are designated as
designated start state. accept states, indicating
successful pattern recognition.

preencoded.png
States and Transitions
Start State
The automaton starts in a defined initial state.

Input Symbol
The automaton reads an input symbol from the input stream.

Transition
Based on the current state and the input symbol, the automaton transitions to

a new state.

Accept State
If the automaton reaches an accept state after processing the input, the input

is accepted.
preencoded.png
Formal Definition and Properties
Definition A finite automaton is a mathematical
model of computation.

Components States, transitions, input alphabet,


start state, and accept states.

Recognition Finite automata recognize patterns in


input strings.

Equivalence Different automata can recognize the


same language, but may have
different structures.

Closure Properties Finite automata are closed under


certain operations, allowing for the
creation of more complex automata.

preencoded.png
Practical Applications of Finite Automata

Text Editors Lexical Analysis Network Security Database Systems


Finite automata are used for Finite automata are employed Finite automata can be used to Finite automata are applied in
tasks like syntax highlighting, to break down code into detect malicious network query optimization and data
code completion, and regular tokens, which are the basic traffic patterns and prevent validation to ensure data
expression searching. building blocks of programs. intrusions. integrity and efficiency.
preencoded.png
Types of Automata
• Finite Automata(FA)
• Deterministic Finite Automata (DFA)
• Non-Deterministic Finite Automata(NFA)
• Pushdown Automata(PDA)
• Turing Machines( TM)
Applications of Finite Automata
• Language Processing: E-mail filter, smart assistants(Siri, Alexa)
• Compiler constructions
• Computer Networks
• Video Games
• Design of digital circuits
• Biomedical problem solving
Types of Finite Automata
• DFA
• NFA
• Non deterministic finite states with epsilon moves
Deterministic Finite Automata (DFA)
Deterministic State Transitions Applications

For a given state and input symbol, there Transitions are clearly defined and DFAs are widely used in lexical analysis,
is only one possible transition to another unambiguous, allowing for predictable regular expression matching, and other
state. behavior. areas of computer science.

preencoded.png
Nondeterministic Finite
Automata (NFA)
1 Nondeterminism 2 Epsilon Transitions
From a given state, multiple NFAs can transition to other
transitions can occur based states without consuming any
on the same input symbol. input symbols.

3 Power of NFAs 4 Conversion to DFA


NFAs offer more flexibility and Any NFA can be converted into
expressiveness compared to an equivalent DFA, but this
DFAs, making them suitable can lead to a significant
for complex pattern increase in the number of
recognition tasks. states.
preencoded.png
The Journey of the Traveler and the Road of Choices
Once upon a time, in a distant land, there was a traveler named Iva. She lived in a
world where every path was clearly defined, but to get to her destination, Iva had to
follow very specific rules. The land she lived in was called the *Kingdom of
Determination, and it had a magical property: once you started on a path, there was
only **one correct route* to reach your destination.

Iva was given a *map*, but it wasn't just an ordinary map. It was a map that told her
which direction to take depending on the symbols she encountered on the road.
Every time she saw a signpost, it had a symbol on it — either an "A" or a "B." Based
on this symbol, she had to choose the next path.

The rules were strict: if she took the wrong path, she wouldn't get to her destination,
and she’d have to start again. However, there was a special property of the paths in
the *Kingdom of Determination: **at any given moment, for each sign she saw, there
was **only one correct path* forward. No matter how many signposts she passed, as
long as she followed the rules on the map, she would eventually reach her
destination.
One day, Iva set out to visit the *Castle of Success*, which was far
away in the kingdom. Her map had clear instructions:

- If she encountered the symbol "A," she would turn left.


- If she saw the symbol "B," she would turn right.
- There were checkpoints along the way, and at each checkpoint,
depending on the path she chose, she would either get closer to
the castle or farther from it.

At each step of the journey, Iva made her decisions based on the
current symbol and the rules on her map. If she followed the rules
exactly, she'd reach the castle. But if she made even one mistake,
she'd be sent back to the start.
Iva’s journey is like a *Deterministic Finite Automaton (DFA)*. In
a DFA:

-Iva represents the *current state*.


- The signposts with symbols ("A" or "B") are the *input
symbols*.
- The map is the set of *transition rules* that tell her which
direction to take.
- The checkpoints are like the *states* in the DFA, and the castle
is the *accepting (final) state*.
- If she follows the map correctly, she’ll reach the final state (the
Castle of Success), just like a DFA processes input symbols and
reaches an accepting state if the input is valid.
Just like Iva can't change her path midway without consequences, a DFA
can only move from one state to another based on specific inputs. There's
*no ambiguity*, no second guesses — everything is determined by the
current state and the input symbol, just like Iva’s journey to the castle.

In the end, Iva successfully reached the Castle of Success, knowing that
she could always trust the rules and transitions on her map to guide her,
as long as she followed them without deviation.
This story shows how *Deterministic Finite Automata* help
us solve problems by following *deterministic rules* — where
each input leads us through a set of states until we either
reach the desired state or realize that the input cannot be
accepted.
• Now lets start solving problems……………………………..
• Design a DFA to accept strings of a’s and b’s ending with string “ab”.
• Design a DFA to accept strings of a’s and b’s having substring “aa”
• Design a DFA to accept strings of a’s and b’s starting with string “ab”
• Design DFA to accept the language of all strings starting with a and
ending with b.
• Design a DFA to accept strings of a’s and b’s with at most 2
consecutive b’s.
https://easyexamnotes.com/dfa-solved-examples/
Design a DFA to accept strings of a’s and b’s except those containing substring aab
DFA to accept strings of a’s and b’s such that each
block of 5 consecutive symbols have atleast 2 a’s
The Quest for Golden Key

Symbols sorting challenge


• What strategies helped you find valid combinations?
• How did working in a team influence your decisions?
• What parallels can you draw between this activity and the concept of
a DFA?
A marble rolling toy
The Language of DFA
That is, the language accepted by a DFA is the set of
strings accepted by the DFA.
Example : The DFA accepts { } because it can go from
the initial state to the accepting state (also the initial
state) without reading any symbol of the alphabet i.e.
by reading an empty string .
Non Deterministic Finite Automata(NFA)
Formal Definition of an NFA
NFA can be represented
NFA examples
Conversion from NFA to DFA
• Subset Construction
• Lazy evaluation
Conversion from NFA to DFA(Subset construction
method)
Finally the DFA will be…………….
• Step 1: Identify the start state of DFA: since q0 is the start state of
NFA, q0 is the start state of DFA too.

• Step 2: Identify the alphabets of DFA: The inputs alphabets of DFA


are the input alphabets of NFA. So, σ = (𝑎, 𝑏)

• Step 3: Identify the transitions of DFA: For each state (q0,q1,q2,....}


in Qd and for each input symbol a in the transition is show as:
DFA Minimization

You might also like