SlideShare a Scribd company logo
1 of 22
Introduction to Formal Languages
Finite Automata
Mobeen Mustafa1
Chapter 5: Finite Automata
We introduce the simplest deterministic theoretical
machines: Finite Automata.
Chapter 5: Finite Automata
Mobeen Mustafa2
 A finite automaton (FA) is the following 3 things:
1. a finite set of states, one of which is designated as the
start state, and some (maybe none) of which are
designated the final states (or accepting states)
2. an alphabet Σ of input letters
3. a finite set of transitions that indicate, for each state
and letter of the input alphabet, the state to go to next
state state
letter
Chapter 5: Finite Automata
Mobeen Mustafa3
The language defined or accepted by a finite
automaton is the set of words that end in a final
state.
If w is in the language defined by a finite
automaton, then we also say that the finite
automaton accepts w.
Chapter 5: Finite Automata
Mobeen Mustafa4
Example: ∑= {a,b}
states = {x,y,z}
start state : x
final states: {z}
a b
x y z
y x z
z z z
aaa: a
x ya ax y y is not final;
aaa is not accepted
aaba: a
x ya bx z z is final;
aaba is accepted
za
transitions:
Chapter 5: Finite Automata
5
x
–
y
z
+
a
a
a
b b
b
a b
x y z
y x z
z z z
Regular expression: (a+b)*b(a+b)*
aaaabba?
bbaabbbb?
Transition Diagram
Chapter 5: Finite Automata
Mobeen Mustafa6
x
–
y
z
+
a
a
a
b b
b
x
–
y
z
+
a
a
a
b
b
a
a
b
x
–
y
z
+a
b
a
b
b
bb
aaaabba?
bbaabbbb?
Chapter 5: Finite Automata
Mobeen Mustafa7
+ a,b
(a+b)(a+b)* = (a+b)+
– +
a
b
a,b
(a+b)*
Chapter 5: Finite Automata
8
No final state
The middle state is not a final state and all transitions that go
into this state do not exit.
–
a
b
a,b
–
a,b
a,b
+a,b
Finite Automata that Accept No Words
Chapter 5: Finite Automata
Mobeen Mustafa9
Two Ways to Study Finite Automata
1. Starting with a finite automaton (FA), analyze it to determine
the language it accepts.
2. Starting from a language, build an FA.
Chapter 5: Finite Automata
Mobeen Mustafa10
Example of 2: The language of all words with an even
number of letters over the alphabet {a,b}:
● Two states: 1 – even number, 2 – odd number
● Start state: 1
● Final state: 1
● The transitions:
a b
1 2 2
2 1 1
1+ 2
a,b
a,b
Chapter 5: Finite Automata
Mobeen Mustafa11
x
–
y
z
+
a,b
a,b
b
a
a(a+b)*
Not necessarily unique:
–
+
a,b
a,b
b
a
+
a,b
Remark: 2 final states
Chapter 5: Finite Automata
Mobeen Mustafa12
From Languages to Finite Automata
 There is not necessarily a unique FA that accepts a given
language.
 Is there always at least one FA:
 that accepts each possible language?
 that defines a language associated with a given regular
expression?
Chapter 5: Finite Automata
Mobeen Mustafa13
Example: Build an FA that accepts all words containing a
triple letter (either aaa or bbb).
1.Build an FA that accepts aaa
2.Add a path that accepts bbb.
3.Add paths for words that contain a’s and b’s before or
after the aaa or bbb.
Chapter 5: Finite Automata
Mobeen Mustafa14
 Does this FA accept the word ababa?
 The word babbb?
 2 ways to get to state 4
 The only way to get to state 2 is by reading an input a.
 The only way to get to state 3 is by reading an input b.
 What language?
1–
2
4
+
a,ba
b 3
a
a
b
b
This example shows that it is
possible to characterize
states by the purposes they
serve.
From Finite Automata to Languages
Chapter 5: Finite Automata
Mobeen Mustafa15
The third letter is b.
(aab + abb + bab + bbb)(a+b)*
(a+b)(a+b)b(a+b)*
The regular expression is not unique.
Is there always at least one regular expression defining the
language accepted by an FA?
+
a,b
a,b
a
b
– a,ba,b
Chapter 5: Finite Automata
Mobeen Mustafa16
Regular expression: baa
A “collecting bucket” state for all other words.
–
a,b
b +a
a
a
bb a,b
Chapter 5: Finite Automata
Mobeen Mustafa17
Regular expression: baa + ab
–
a,b
b +aa
bb a,b
+ b a
a,b a
Chapter 5: Finite Automata
Mobeen Mustafa
18
+
a,b
a,b
+
b
a
ba
– +
a
a
bb
– +
a
b
ab
Λ (a+b)*a + Λ
Words that do not end in b.
(a+b)*a
Words that end
in a.
?
Chapter 5: Finite Automata
Mobeen Mustafa19
The only letter that can change state is a.
(b*ab*)(ab*ab*)*
an odd number of a’s
– +
a
a
bb
Chapter 5: Finite Automata
Mobeen Mustafa20
Words that contain a double a
(a+b)*aa(a+b)*
Start state: the previous letter (if there is one) was not an a.
Middle state: we have just seen an a that was not preceded
by an a.
Final state: we have seen a double a.
– +
a
b
a,bb
a
Chapter 5: Finite Automata
Mobeen Mustafa21
+
b
a
ba
+
a
b
a
b
–
b
a
+
ba
–
a
a
a
b
b
b
aabbaabb
Chapter 5: Finite Automata
Mobeen Mustafa22
1
+
2
b
b
a
3 4
b
b
a a a
The Language EVEN-EVEN

More Related Content

What's hot

What's hot (20)

Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
 
Lesson 10
Lesson 10Lesson 10
Lesson 10
 
Lesson 12
Lesson 12Lesson 12
Lesson 12
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
Pushdown Automata Theory
Pushdown Automata TheoryPushdown Automata Theory
Pushdown Automata Theory
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal Forms
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Finite automata
Finite automataFinite automata
Finite automata
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Ch2 finite automaton
Ch2 finite automatonCh2 finite automaton
Ch2 finite automaton
 
Push down automata
Push down automataPush down automata
Push down automata
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
TOC 5 | Regular Expressions
TOC 5 | Regular ExpressionsTOC 5 | Regular Expressions
TOC 5 | Regular Expressions
 

More from Mobeen Mustafa

More from Mobeen Mustafa (11)

Theory of automata
Theory of automataTheory of automata
Theory of automata
 
Language
LanguageLanguage
Language
 
Mathematical preliminaries in Automata
Mathematical preliminaries in AutomataMathematical preliminaries in Automata
Mathematical preliminaries in Automata
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
 
Lect3 ch15-unit2
Lect3 ch15-unit2Lect3 ch15-unit2
Lect3 ch15-unit2
 
Incremental Model
Incremental ModelIncremental Model
Incremental Model
 
RAD
RADRAD
RAD
 
Types of graphics cards
Types of graphics cardsTypes of graphics cards
Types of graphics cards
 
convert number to string
convert number to string convert number to string
convert number to string
 
Process or preparing effective b.m
Process or preparing effective b.mProcess or preparing effective b.m
Process or preparing effective b.m
 
Lecture1
Lecture1Lecture1
Lecture1
 

Recently uploaded

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
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.docxRamakrishna Reddy Bijjam
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
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_.pdfSherif Taha
 
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...Poonam Aher Patil
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
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
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
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
 
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...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

FInite Automata

  • 1. Introduction to Formal Languages Finite Automata Mobeen Mustafa1 Chapter 5: Finite Automata We introduce the simplest deterministic theoretical machines: Finite Automata.
  • 2. Chapter 5: Finite Automata Mobeen Mustafa2  A finite automaton (FA) is the following 3 things: 1. a finite set of states, one of which is designated as the start state, and some (maybe none) of which are designated the final states (or accepting states) 2. an alphabet Σ of input letters 3. a finite set of transitions that indicate, for each state and letter of the input alphabet, the state to go to next state state letter
  • 3. Chapter 5: Finite Automata Mobeen Mustafa3 The language defined or accepted by a finite automaton is the set of words that end in a final state. If w is in the language defined by a finite automaton, then we also say that the finite automaton accepts w.
  • 4. Chapter 5: Finite Automata Mobeen Mustafa4 Example: ∑= {a,b} states = {x,y,z} start state : x final states: {z} a b x y z y x z z z z aaa: a x ya ax y y is not final; aaa is not accepted aaba: a x ya bx z z is final; aaba is accepted za transitions:
  • 5. Chapter 5: Finite Automata 5 x – y z + a a a b b b a b x y z y x z z z z Regular expression: (a+b)*b(a+b)* aaaabba? bbaabbbb? Transition Diagram
  • 6. Chapter 5: Finite Automata Mobeen Mustafa6 x – y z + a a a b b b x – y z + a a a b b a a b x – y z +a b a b b bb aaaabba? bbaabbbb?
  • 7. Chapter 5: Finite Automata Mobeen Mustafa7 + a,b (a+b)(a+b)* = (a+b)+ – + a b a,b (a+b)*
  • 8. Chapter 5: Finite Automata 8 No final state The middle state is not a final state and all transitions that go into this state do not exit. – a b a,b – a,b a,b +a,b Finite Automata that Accept No Words
  • 9. Chapter 5: Finite Automata Mobeen Mustafa9 Two Ways to Study Finite Automata 1. Starting with a finite automaton (FA), analyze it to determine the language it accepts. 2. Starting from a language, build an FA.
  • 10. Chapter 5: Finite Automata Mobeen Mustafa10 Example of 2: The language of all words with an even number of letters over the alphabet {a,b}: ● Two states: 1 – even number, 2 – odd number ● Start state: 1 ● Final state: 1 ● The transitions: a b 1 2 2 2 1 1 1+ 2 a,b a,b
  • 11. Chapter 5: Finite Automata Mobeen Mustafa11 x – y z + a,b a,b b a a(a+b)* Not necessarily unique: – + a,b a,b b a + a,b Remark: 2 final states
  • 12. Chapter 5: Finite Automata Mobeen Mustafa12 From Languages to Finite Automata  There is not necessarily a unique FA that accepts a given language.  Is there always at least one FA:  that accepts each possible language?  that defines a language associated with a given regular expression?
  • 13. Chapter 5: Finite Automata Mobeen Mustafa13 Example: Build an FA that accepts all words containing a triple letter (either aaa or bbb). 1.Build an FA that accepts aaa 2.Add a path that accepts bbb. 3.Add paths for words that contain a’s and b’s before or after the aaa or bbb.
  • 14. Chapter 5: Finite Automata Mobeen Mustafa14  Does this FA accept the word ababa?  The word babbb?  2 ways to get to state 4  The only way to get to state 2 is by reading an input a.  The only way to get to state 3 is by reading an input b.  What language? 1– 2 4 + a,ba b 3 a a b b This example shows that it is possible to characterize states by the purposes they serve. From Finite Automata to Languages
  • 15. Chapter 5: Finite Automata Mobeen Mustafa15 The third letter is b. (aab + abb + bab + bbb)(a+b)* (a+b)(a+b)b(a+b)* The regular expression is not unique. Is there always at least one regular expression defining the language accepted by an FA? + a,b a,b a b – a,ba,b
  • 16. Chapter 5: Finite Automata Mobeen Mustafa16 Regular expression: baa A “collecting bucket” state for all other words. – a,b b +a a a bb a,b
  • 17. Chapter 5: Finite Automata Mobeen Mustafa17 Regular expression: baa + ab – a,b b +aa bb a,b + b a a,b a
  • 18. Chapter 5: Finite Automata Mobeen Mustafa 18 + a,b a,b + b a ba – + a a bb – + a b ab Λ (a+b)*a + Λ Words that do not end in b. (a+b)*a Words that end in a. ?
  • 19. Chapter 5: Finite Automata Mobeen Mustafa19 The only letter that can change state is a. (b*ab*)(ab*ab*)* an odd number of a’s – + a a bb
  • 20. Chapter 5: Finite Automata Mobeen Mustafa20 Words that contain a double a (a+b)*aa(a+b)* Start state: the previous letter (if there is one) was not an a. Middle state: we have just seen an a that was not preceded by an a. Final state: we have seen a double a. – + a b a,bb a
  • 21. Chapter 5: Finite Automata Mobeen Mustafa21 + b a ba + a b a b – b a + ba – a a a b b b aabbaabb
  • 22. Chapter 5: Finite Automata Mobeen Mustafa22 1 + 2 b b a 3 4 b b a a a The Language EVEN-EVEN