SlideShare une entreprise Scribd logo
1  sur  22
Akhil Kaushik
Asstt. Prof., CE Deptt.,
TIT Bhiwani
NFA & DFA
Regular Expression
• letter = [a –z] or [A –Z]
• digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 or [0-9]
• sign = [ + | -]
• Decimal = (sign)?(digit)+
• Identifier = (letter)(letter | digit)*
• Float = (sign)? (digit) +.+ (digit)*
Finite State Automata (FSA)
Finite State Automata (FSA)
• There are two main kinds of FSA:-
– Non-Deterministic Finite Automata (NFA): at a
particular state, a unique path may not be determined for
each input alphabet.
– Deterministic Finite Automata (DFA): at a particular
state, a unique path determined for each input alphabet.
Finite State Automata (FSA)
• For every non-deterministic automata, there is an
equivalent deterministic automata.
• The below NFA is equivalent to the regular
expression/ab*ca?/.
NFA
• In a NFA, for each state there can be zero, one,
two, or more transitions corresponding to a
particular symbol.
• For a particular input symbol, the machine can move
to any combination of the states in the machine.
Hence, it is called NFA.
• Only NFA state automaton can have an ε transition.
• The procedure is like: RE → NFA → DFA → Tables
NFA
An NFA can be represented by a 5-tuple (Q, Σ, δ, q0,
F) where:−
• Q is a finite set of states.
• Σ is a finite set of symbols called the alphabets.
• δ is the transition function where δ: Q × Σ → 2Q
• q0 is the initial state & F is the final state
(Here the power set of Q (2Q) has been taken because in
case of NFA, from a state, transition can occur to any
combination of Q states)
NFA – State Digrams
• Represented by digraphs called state diagram:
used to graphically represent finite state machines
to give an abstract description of the behavior of a
system.
NFA Examples
NFA Examples
00 (0 + 1)*
DFA
• In DFA, for each input symbol, one can determine
the state to which the machine will move. Hence, it
is called Deterministic Automaton.
• As it has a finite number of states, the machine is
called Deterministic Finite Machine.
• Q is a finite set of states.
• Σ is a finite set of symbols called the alphabet.
• δ is the transition function where δ: Q × Σ → Q
NFA vs DFA
• In NFA each pair of state
and input symbol can
have many possible next
states.
• NFA can use empty string
transition.
• NFA is easier to construct.
• NFA requires less space.
• In DFA the next possible
state is distinctly set.
• DFA cannot use empty
string transition.
• It is more difficult to
construct DFA.
• DFA requires more space.
NFA to DFA
NFA to DFA
NFA to DFA
NFA to DFA
NFA to DFA
NFA to DFA
NFA to DFA
Transition Table of DFA
DFA Minimization
• Make a partition of final & non-final states:
• T = { {E}, {A, B, C, D} }
• T = { {E}, {A, B, C}, {D} }
• T = { {E}, {A, C}, {B}, {D} } or
• T = { {E}, {A1}, {B}, {D} }
Akhil Kaushik
akhilkaushik05@gmail.com
9416910303
CONTACT ME AT:
Akhil Kaushik
akhilkaushik05@gmail.com
9416910303
THANK YOU !!!

Contenu connexe

Tendances

Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
Adel Al-Ofairi
 

Tendances (20)

Finite automata
Finite automataFinite automata
Finite automata
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler design
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA Conversion
 
context free language
context free languagecontext free language
context free language
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
Pda
PdaPda
Pda
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 

Similaire à NFA & DFA

deterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfdeterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdf
AmayJaiswal4
 
finiteautomata-160104102657.pptx
finiteautomata-160104102657.pptxfiniteautomata-160104102657.pptx
finiteautomata-160104102657.pptx
StudyvAbhi
 
Lexical analysis, syntax analysis, semantic analysis. Ppt
Lexical analysis, syntax analysis, semantic analysis. PptLexical analysis, syntax analysis, semantic analysis. Ppt
Lexical analysis, syntax analysis, semantic analysis. Ppt
ovidlivi91
 
Finite Automata fgyft rtrt rr uuy y.pptx
Finite Automata fgyft rtrt  rr uuy y.pptxFinite Automata fgyft rtrt  rr uuy y.pptx
Finite Automata fgyft rtrt rr uuy y.pptx
AsadBaig49
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
FariyaTasneem1
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
raosir123
 

Similaire à NFA & DFA (20)

deterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfdeterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdf
 
FINITE AUTOMATA
FINITE AUTOMATAFINITE AUTOMATA
FINITE AUTOMATA
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
introduction-190804060837.pptx
introduction-190804060837.pptxintroduction-190804060837.pptx
introduction-190804060837.pptx
 
Implementation of lexical analyser
Implementation of lexical analyserImplementation of lexical analyser
Implementation of lexical analyser
 
finiteautomata-160104102657.pptx
finiteautomata-160104102657.pptxfiniteautomata-160104102657.pptx
finiteautomata-160104102657.pptx
 
Regular Expression to Finite Automata
Regular Expression to Finite AutomataRegular Expression to Finite Automata
Regular Expression to Finite Automata
 
Finite automata
Finite automataFinite automata
Finite automata
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.ppt
 
5. NFA & DFA.pdf
5. NFA & DFA.pdf5. NFA & DFA.pdf
5. NFA & DFA.pdf
 
Lexical analysis, syntax analysis, semantic analysis. Ppt
Lexical analysis, syntax analysis, semantic analysis. PptLexical analysis, syntax analysis, semantic analysis. Ppt
Lexical analysis, syntax analysis, semantic analysis. Ppt
 
TOC Introduction
TOC Introduction TOC Introduction
TOC Introduction
 
Finite Automata fgyft rtrt rr uuy y.pptx
Finite Automata fgyft rtrt  rr uuy y.pptxFinite Automata fgyft rtrt  rr uuy y.pptx
Finite Automata fgyft rtrt rr uuy y.pptx
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
 
Automata
AutomataAutomata
Automata
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 

Plus de Akhil Kaushik

Plus de Akhil Kaushik (20)

Symbol Table, Error Handler & Code Generation
Symbol Table, Error Handler & Code GenerationSymbol Table, Error Handler & Code Generation
Symbol Table, Error Handler & Code Generation
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Lexical Analyzer Implementation
Lexical Analyzer ImplementationLexical Analyzer Implementation
Lexical Analyzer Implementation
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
Basic programs in Python
Basic programs in PythonBasic programs in Python
Basic programs in Python
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 

Dernier

Dernier (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

NFA & DFA

  • 1. Akhil Kaushik Asstt. Prof., CE Deptt., TIT Bhiwani NFA & DFA
  • 2. Regular Expression • letter = [a –z] or [A –Z] • digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 or [0-9] • sign = [ + | -] • Decimal = (sign)?(digit)+ • Identifier = (letter)(letter | digit)* • Float = (sign)? (digit) +.+ (digit)*
  • 4. Finite State Automata (FSA) • There are two main kinds of FSA:- – Non-Deterministic Finite Automata (NFA): at a particular state, a unique path may not be determined for each input alphabet. – Deterministic Finite Automata (DFA): at a particular state, a unique path determined for each input alphabet.
  • 5. Finite State Automata (FSA) • For every non-deterministic automata, there is an equivalent deterministic automata. • The below NFA is equivalent to the regular expression/ab*ca?/.
  • 6. NFA • In a NFA, for each state there can be zero, one, two, or more transitions corresponding to a particular symbol. • For a particular input symbol, the machine can move to any combination of the states in the machine. Hence, it is called NFA. • Only NFA state automaton can have an ε transition. • The procedure is like: RE → NFA → DFA → Tables
  • 7. NFA An NFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:− • Q is a finite set of states. • Σ is a finite set of symbols called the alphabets. • δ is the transition function where δ: Q × Σ → 2Q • q0 is the initial state & F is the final state (Here the power set of Q (2Q) has been taken because in case of NFA, from a state, transition can occur to any combination of Q states)
  • 8. NFA – State Digrams • Represented by digraphs called state diagram: used to graphically represent finite state machines to give an abstract description of the behavior of a system.
  • 11. DFA • In DFA, for each input symbol, one can determine the state to which the machine will move. Hence, it is called Deterministic Automaton. • As it has a finite number of states, the machine is called Deterministic Finite Machine. • Q is a finite set of states. • Σ is a finite set of symbols called the alphabet. • δ is the transition function where δ: Q × Σ → Q
  • 12. NFA vs DFA • In NFA each pair of state and input symbol can have many possible next states. • NFA can use empty string transition. • NFA is easier to construct. • NFA requires less space. • In DFA the next possible state is distinctly set. • DFA cannot use empty string transition. • It is more difficult to construct DFA. • DFA requires more space.
  • 21. DFA Minimization • Make a partition of final & non-final states: • T = { {E}, {A, B, C, D} } • T = { {E}, {A, B, C}, {D} } • T = { {E}, {A, C}, {B}, {D} } or • T = { {E}, {A1}, {B}, {D} }
  • 22. Akhil Kaushik akhilkaushik05@gmail.com 9416910303 CONTACT ME AT: Akhil Kaushik akhilkaushik05@gmail.com 9416910303 THANK YOU !!!