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

Automata Dfa vs Nfa

Finite Automata is a mathematical model used in formal language theory for pattern recognition and processing regular languages, with two main types: Deterministic Finite Automaton (DFA) and Nondeterministic Finite Automaton (NFA). DFAs have a unique transition for each input symbol, while NFAs allow multiple transitions and ε-transitions. Both types are widely used in fields such as compiler design, text processing, and artificial intelligence.

Uploaded by

basakj216
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)
1 views

Automata Dfa vs Nfa

Finite Automata is a mathematical model used in formal language theory for pattern recognition and processing regular languages, with two main types: Deterministic Finite Automaton (DFA) and Nondeterministic Finite Automaton (NFA). DFAs have a unique transition for each input symbol, while NFAs allow multiple transitions and ε-transitions. Both types are widely used in fields such as compiler design, text processing, and artificial intelligence.

Uploaded by

basakj216
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/ 10

Introduction to Finite Automata

Introduction to Finite Automata


● Finite Automata is a mathematical model of computation used in formal language theory.
● It helps in recognizing patterns and processing regular languages. It is a simple machine with finite
states that transitions between states based on input symbols.
Two main types:
1. Deterministic Finite Automaton (DFA)
2. Nondeterministic Finite Automaton (NFA)

Uses of Finite Automata


Finite Automata (FA) is widely used in various fields of computer science Including –
➠ Compiler Design
➠ Text Pattern Matching
➠ Digital Circuit Design
➠ Artificial Intelligence (AI) & Natural Language Processing (NLP)
Deterministic Finite Automaton(DFA)
➠ DFA (Deterministic Finite Automaton) is a state machine where each input has exactly one
transition from a given state.
A DFA consists of:
● Q: Finite set of states
● Σ: Finite set of input symbols (alphabet)
● δ: Transition function δ:Q×Σ→Q\delta: Q × Σ → Qδ:Q×Σ→Q
● q₀: Initial (start) state
● F: Set of accept (final) states
➠ Key Property: No ε (epsilon) transitions, and every input has a unique path.

➠ Working Technique of DFA (Deterministic Finite Automaton)


1. Start from the initial state and read input symbols one by one.
2. Move to the next state according to a fixed transition rule.
3. Repeat the process until the input is fully read.
4. If the final state is an accepting state, accept; otherwise, reject.
Non-deterministic Finite Automaton(NFA)

A Non-deterministic Finite Automaton (NFA) is a mathematical model used to recognize patterns within input
strings. Unlike a Deterministic Finite Automaton (DFA), where for each state and input symbol, there is exactly one
possible transition, an NFA allows multiple transitions or even no transition at all for a given state and input symbol.
How it works:
★ An NFA accepts a string by ending in a final state.
★ It rejects a string by ending in a non-final state or a dead configuration.
★ An NFA can transition without input, called an ϵ-transition.
★ An NFA can have multiple transitions for a given state and input symbol.
Components of NFA:
An NFA is a 5-tuple (Q, Σ, Δ, s, W) where,
➔ Q is a finite set of states
➔ Σ is the alphabet
➔ Δ is the transition relation
➔ s is the start state
Differences Between DFA & NFA
Feature DFA (Deterministic Finite NFA (Non-deterministic Finite
Automaton) Automaton)

Determinism Exactly one transition per input Multiple transitions or none for an
symbol. input symbol.

Epsilon (ε) Moves Not allowed. Allowed, which changes without input.

Complexity Easier to implement but may require More flexible but can be harder to
more states. implement.

Acceptance A string is accepted if it reaches a final A string is accepted if any path reaches
state via a unique path. a final state.

Conversion Cannot be converted to NFA. Can be converted to an equivalent


DFA.

Speed & Efficiency Faster execution due to deterministic Can be slower due to multiple possible
nature. transitions.
Example of DFA
A DFA is a 5-tuple (Q, Σ, δ, q₀, F):
● Q = {q₀, q₁} (Set of states)
● Σ = {0, 1} (Alphabet)
● q₀ (Start state)
● F = {q₁} (Accepting state)
● δ (Transition function):
Current State Input Next State
q₀ 0 q₀
q₀ 1 q₁
q₁ 0 q₀
q₁ 1 q₁
Example of NFA
● Q = {q₀, q₁, q₂} (Set of states)
● Σ = {a, b} (Alphabet)
● q₀ = Start state
● F = {q₂} (Accepting state)
● δ (Transition function):
Current State Input Next State
q₀ a {q₀, q₁}
q₀ b {q₀}
q₁ a {q₁}
q₁ b {q₂}
q₂ a {q₂}
q₂ b {q₂}
Conversion of NFA to DFA
● Start with the initial state of NFA
The DFA's initial state is the ε-closure of the NFA's initial state.
● Compute ε-closure (if ε-transitions exist)
The ε-closure of a state includes all states reachable from it via ε-transitions.
● Construct new states for DFA
Each state in the DFA represents a set of NFA states.
● Find transitions for each new state
Compute the ε-closure of the union of NFA transitions for an input symbol.
● Repeat until all states are processed
Continue creating new DFA states until no more new subsets appear.
● Define final states in DFA
Any DFA state that contains an NFA final state becomes a final state.
Applications of DFA and NFA
❏ Spell Checker and Text processing: DFAs are used to verify if a word is exists in a dictionary
by modeling word structure.
❏ Natural language processing: Used in tokenization and syntax checking for language parsing.
❏ DNA and protein sequence matching: NFAs are used to find genetic patterns and analyze
DNA sequences.
❏ Lexical Analysis: DFAs are used in lexical analysis, which is the process of breaking down a
stream of text into individual words, phrases, and other elements.
❏ Cybersecurity:DFAs are used in cybersecurity to detect and prevent malicious activities by
recognizing patterns in network traffic.

Searching text DNA sequencing


CONCLUSION
● Finite Automata (DFA and NFA) are core to computer science.
● DFA is simpler to implement and deterministic, whereas NFA is flexible but can be
convertible.
● Both are extensively employed in various disciplines, ranging from programming languages
to artificial intelligence.

REFERENCES
1. Wikipedia
2. https://www.researchgate.net/publication/269628569_DNA_Pattern_Analysis_using_Finite_
Automata
3. https://www.geeksforgeeks.org/application-of-deterministic-finite-automata-dfa/
4. Michael Sipser, Introduction to the Theory of Computation, PWS Publishing.

You might also like