SlideShare a Scribd company logo
1 of 11
Download to read offline
15-251
Great Theoretical Ideas
in Computer Science
Deterministic
Finite Automata
Lecture 20 (October 30, 2008)
Let me show you a
machine so simple
that you can
understand it in less
than two minutes
0
0,1
00
1
1
1
0111 111
11
1
The machine accepts a string if the
process ends in a double circle
0
0,1
00
1
1
1
The machine accepts a string if the
process ends in a double circle
Anatomy of a Deterministic Finite
Automaton
states
states
q0
q1
q2
q3
start state (q0)
accept states (F)
Anatomy of a Deterministic Finite
Automaton
0
0,1
00
1
1
1
q0
q1
q2
q3
The alphabet of a finite automaton is the set
where the symbols come from:
The language of a finite automaton is the set
of strings that it accepts
{0,1}
0,1q0
L(M) = All strings of 0s and 1s!
The Language of Machine M
q0 q1
0 0
1
1
L(M) = { w | w has an even number of 1s}
An alphabet ! is a finite set (e.g., ! = {0,1})
A string over ! is a finite-length sequence of
elements of !. The set of all strings over ! is
denoted by !*.
For x a string, |x| is the length of x
The unique string of length 0 will be denoted
by " and will be called the empty or null string
Notation
A language over ! is a set of strings over !
Q is the set of states
! is the alphabet
" : Q # ! # Q is the transition function
q0 $ Q is the start state
F % Q is the set of accept states
A finite automaton is a 5-tuple M = (Q, !, ", q0, F)
L(M) = the language of machine M
= set of all strings machine M accepts
Q = {q0, q1, q2, q3}
! = {0,1}
" : Q # ! " Q transition function
q0 $ Q is start state
F = {q1, q2} % Q accept states
M = (Q, !, ", q0, F)
where
" 0 1
q0 q0 q1
q1 q2 q2
q2 q3 q2
q3 q0 q2
q2
0
0,1
00
1
1
1
q0
q1
q3
M
Input String Result
aba
aabb
aabba
&
b
b a
b
a
a
a
b
a
b
Accept
Reject
Accept
Accept
“ABA” The Automaton
What machine accepts this
language?
L = all strings in {a,b}* that
contain at least one a
b a,b
a
What machine accepts this
language?
L = strings with an odd number of b’s
and any number of a’s
a a
b
b
What is the language accepted by
this machine?
L = any string ending with a b
a b
b
a
What is the language accepted by
this machine?
b a,b
a
b
a
L(M) = any string with at least two a’s
What machine accepts this
language?
L = any string with an a and a b
a
b
b
a
a
a,b
b
What machine accepts this
language?
L = strings with an even number of ab pairs
a
b
b
a
a
b
a
b
q q00
1 0
1
q0 q001
0 0 1
0,1
Build an automaton that accepts all and only
those strings that contain 001
L = all strings containing ababb as a
consecutive substring
q qab
b
b
qa qaba
a b a
a
qabab
b qababb
b
a,b
aa
Invariant:
I am state s exactly when s is the longest suffix
of the input (so far) forming a prefix of ababb.
Input: Text T of length t, string S of length n
The “Grep” Problem
Problem: Does string S appear inside text T?
a1, a2, a3, a4, a5, …, at
Naïve method:
Cost: Roughly nt comparisons
Automata Solution
Build a machine M that accepts any string
with S as a consecutive substring
Feed the text to M
Cost:
As luck would have it, the Knuth, Morris,
Pratt algorithm builds M quickly
t comparisons + time to build M
Grep
Coke Machines
Thermostats (fridge)
Elevators
Train Track Switches
Lexical Analyzers for Parsers
Real-life Uses of DFAs
A language is regular if it is
recognized by a deterministic
finite automaton
L = { w | w contains 001} is regular
L = { w | w has an even number of 1s} is regular
Union Theorem
Given two languages, L1 and L2, define
the union of L1 and L2 as
L1 ' L2 = { w | w $ L1 or w $ L2 }
Theorem: The union of two regular
languages is also a regular language
Theorem: The union of two regular
languages is also a regular language
Proof Sketch: Let
M1 = (Q1, !, "1, q0, F1) be finite automaton for L1
and
M2 = (Q2, !, "2, q0, F2) be finite automaton for L2
We want to construct a finite automaton
M = (Q, !, ", q0, F) that recognizes L = L1 ' L2
1
2
Idea: Run both M1 and M2 at the same time!
Q = pairs of states, one from M1 and one from M2
= { (q1, q2) | q1 $ Q1 and q2 $ Q2 }
= Q1 # Q2
Theorem: The union of two regular
languages is also a regular language
q0 q1
0
0
1
1
p0 p1
1
1
0
0
q0,p0 q1,p0
1
1
q0,p1 q1,p1
1
1
0
0
0
0
Automaton for Union
q0,p0 q1,p0
1
1
q0,p1 q1,p1
1
1
0
0
0
0
Automaton for Intersection
Theorem: The union of two regular
languages is also a regular language
Corollary: Any finite language is
regular
The Regular Operations
Union: A ' B = { w | w $ A or w $ B }
Intersection: A ( B = { w | w $ A and w $ B }
Negation: ¬A = { w | w ) A }
Reverse: AR = { w1 …wk | wk …w1 $ A }
Concatenation: A * B = { vw | v $ A and w $ B }
Star: A* = { w1 …wk | k ! 0 and each wi $ A }
Regular Languages Are
Closed Under The
Regular Operations
We have seen part of the proof for
Union. The proof for intersection is very
similar. The proof for negation is easy.
Are all
languages
regular?
i.e., a bunch of a’s followed by an
equal number of b’s
Consider the language L = { anbn | n > 0 }
No finite automaton accepts this language
Can you prove this?
anbn is not regular.
No machine has
enough states to
keep track of the
number of a’s it
might encounter
That is a fairly weak
argument
Consider the following
example…
L = strings where the # of occurrences of
the pattern ab is equal to the number of
occurrences of the pattern ba
Can’t be regular. No machine has
enough states to keep track of the
number of occurrences of ab
M accepts only the strings with an
equal number of ab’s and ba’s!
b
b
a
b
a
a
a
b
a
b
Let me show you a
professional strength
proof that anbn is not
regular…
Pigeonhole principle:
Given n boxes and m > n
objects, at least one box
must contain more than
one object
Letterbox principle:
If the average number of
letters per box is x, then
some box will have at
least x letters (similarly,
some box has at most x)
Theorem: L= {anbn | n > 0 } is not regular
Proof (by contradiction):
Assume that L is regular
Then there exists a machine M with k states
that accepts L
For each 0 + i + k, let Si be the state M is in
after reading ai
,i,j + k such that Si = Sj, but i - j
M will do the same thing on aibi and ajbi
But a valid M must reject ajbi and accept aibi
Advertisement
You can learn much more about these
creatures in the FLAC course.
Formal Languages, Automata, and
Computation
• There is a unique smallest
automaton for any regular language
• It can be found by a fast algorithm.
Deterministic Finite
Automata
• Definition
• Testing if they accept a string
• Building automata
Regular Languages
• Definition
• Closed Under Union,
Intersection, Negation
• Using Pigeonhole Principle to
show language not regular
Here’s What
You Need to
Know…

More Related Content

What's hot

Automata
AutomataAutomata
AutomataGaditek
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMRajendran
 
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
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 5Srimatre K
 
3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on plSampath Kumar S
 
Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4Srimatre K
 
01. Theory of Computing
01. Theory of Computing01. Theory of Computing
01. Theory of Computingrabiul souvon
 
Toc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computationToc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computationnarayan dudhe
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introductionNAMRATA BORKAR
 
Top school in ghaziabad
Top school in ghaziabadTop school in ghaziabad
Top school in ghaziabadEdhole.com
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
A theory of timed automata
A theory of timed automataA theory of timed automata
A theory of timed automatanico.pao
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Abhimanyu Mishra
 
Finite automata
Finite automataFinite automata
Finite automataPusp Sunar
 

What's hot (20)

Automata
AutomataAutomata
Automata
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
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
 
Fsa
FsaFsa
Fsa
 
3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl
 
Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4
 
Ch2 finite automaton
Ch2 finite automatonCh2 finite automaton
Ch2 finite automaton
 
01. Theory of Computing
01. Theory of Computing01. Theory of Computing
01. Theory of Computing
 
Toc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computationToc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computation
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
 
Top school in ghaziabad
Top school in ghaziabadTop school in ghaziabad
Top school in ghaziabad
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
A theory of timed automata
A theory of timed automataA theory of timed automata
A theory of timed automata
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Finite automata
Finite automataFinite automata
Finite automata
 
Theory of computation / Post’s Correspondence Problems (PCP)
Theory of computation / Post’s Correspondence Problems (PCP)Theory of computation / Post’s Correspondence Problems (PCP)
Theory of computation / Post’s Correspondence Problems (PCP)
 

Viewers also liked

Library orientation classroom_delivery_2014
Library orientation  classroom_delivery_2014Library orientation  classroom_delivery_2014
Library orientation classroom_delivery_2014LesleySmith40
 
Library orientation classroom_delivery_2014
Library orientation  classroom_delivery_2014Library orientation  classroom_delivery_2014
Library orientation classroom_delivery_2014LesleySmith40
 
Library orientation classroom_delivery_2014 _ work in progress
Library orientation  classroom_delivery_2014 _ work in progressLibrary orientation  classroom_delivery_2014 _ work in progress
Library orientation classroom_delivery_2014 _ work in progressLesleySmith40
 
Photo analysis
Photo analysisPhoto analysis
Photo analysislolman1234
 
2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress
2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress
2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congressgoodnesscompany
 
Successful research ppt
Successful research pptSuccessful research ppt
Successful research pptLesleySmith40
 
Inside dia de los muertos
Inside dia de los muertosInside dia de los muertos
Inside dia de los muertosErikaCabrales
 
Actividad martha-organigrama
Actividad  martha-organigramaActividad  martha-organigrama
Actividad martha-organigramaCarlos GP
 
Set Design to Bus Stop
Set Design to Bus StopSet Design to Bus Stop
Set Design to Bus Stopmartaepomba
 
Lesson 11 - Yonder Mountain - 2016
Lesson 11 - Yonder Mountain - 2016Lesson 11 - Yonder Mountain - 2016
Lesson 11 - Yonder Mountain - 2016Mister Valverde
 
Lesson 9 kamishibai man - 2016
Lesson 9  kamishibai man - 2016Lesson 9  kamishibai man - 2016
Lesson 9 kamishibai man - 2016Mister Valverde
 
Presentation linux vs windows
Presentation linux vs windowsPresentation linux vs windows
Presentation linux vs windowsgunturpramasatya
 

Viewers also liked (13)

Library orientation classroom_delivery_2014
Library orientation  classroom_delivery_2014Library orientation  classroom_delivery_2014
Library orientation classroom_delivery_2014
 
Library orientation classroom_delivery_2014
Library orientation  classroom_delivery_2014Library orientation  classroom_delivery_2014
Library orientation classroom_delivery_2014
 
Library orientation classroom_delivery_2014 _ work in progress
Library orientation  classroom_delivery_2014 _ work in progressLibrary orientation  classroom_delivery_2014 _ work in progress
Library orientation classroom_delivery_2014 _ work in progress
 
Photo analysis
Photo analysisPhoto analysis
Photo analysis
 
2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress
2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress
2013 Patrick Goodness lecture at the 6th Annual World Medical Tourism Congress
 
Successful research ppt
Successful research pptSuccessful research ppt
Successful research ppt
 
Inside dia de los muertos
Inside dia de los muertosInside dia de los muertos
Inside dia de los muertos
 
Actividad martha-organigrama
Actividad  martha-organigramaActividad  martha-organigrama
Actividad martha-organigrama
 
Set Design to Bus Stop
Set Design to Bus StopSet Design to Bus Stop
Set Design to Bus Stop
 
Lesson 11 - Yonder Mountain - 2016
Lesson 11 - Yonder Mountain - 2016Lesson 11 - Yonder Mountain - 2016
Lesson 11 - Yonder Mountain - 2016
 
Lesson 9 kamishibai man - 2016
Lesson 9  kamishibai man - 2016Lesson 9  kamishibai man - 2016
Lesson 9 kamishibai man - 2016
 
Resume_of_Vasudevan - Hadoop
Resume_of_Vasudevan - HadoopResume_of_Vasudevan - Hadoop
Resume_of_Vasudevan - Hadoop
 
Presentation linux vs windows
Presentation linux vs windowsPresentation linux vs windows
Presentation linux vs windows
 

Similar to Flat

Automata
AutomataAutomata
AutomataGaditek
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghggggggggggggggggggggggggggggggggggadugnanegero
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdfT17Rockstar
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptxssuser47f7f2
 
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd edLecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd edzoobiarana76
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata Muhammad Love Kian
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with OutputMustafa Saeed
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...parmeet834
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
Seminar on Quantum Automata and Languages
Seminar on Quantum Automata and LanguagesSeminar on Quantum Automata and Languages
Seminar on Quantum Automata and Languagesranjanphu
 
Seminar on quantum automata and Languages
Seminar on quantum automata and LanguagesSeminar on quantum automata and Languages
Seminar on quantum automata and Languagesranjanphu
 
@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).pdfFariyaTasneem1
 

Similar to Flat (20)

lecture02.ppt
lecture02.pptlecture02.ppt
lecture02.ppt
 
Automata
AutomataAutomata
Automata
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggg
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdf
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd edLecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
 
CS 5th.pptx
CS 5th.pptxCS 5th.pptx
CS 5th.pptx
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with Output
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Automata Theory
Automata TheoryAutomata Theory
Automata Theory
 
Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
 
Seminar on Quantum Automata and Languages
Seminar on Quantum Automata and LanguagesSeminar on Quantum Automata and Languages
Seminar on Quantum Automata and Languages
 
Seminar on quantum automata and Languages
Seminar on quantum automata and LanguagesSeminar on quantum automata and Languages
Seminar on quantum automata and Languages
 
Dfa h11
Dfa h11Dfa h11
Dfa h11
 
@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
 

Recently uploaded

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 

Recently uploaded (20)

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Flat

  • 1. 15-251 Great Theoretical Ideas in Computer Science Deterministic Finite Automata Lecture 20 (October 30, 2008) Let me show you a machine so simple that you can understand it in less than two minutes 0 0,1 00 1 1 1 0111 111 11 1 The machine accepts a string if the process ends in a double circle
  • 2. 0 0,1 00 1 1 1 The machine accepts a string if the process ends in a double circle Anatomy of a Deterministic Finite Automaton states states q0 q1 q2 q3 start state (q0) accept states (F) Anatomy of a Deterministic Finite Automaton 0 0,1 00 1 1 1 q0 q1 q2 q3 The alphabet of a finite automaton is the set where the symbols come from: The language of a finite automaton is the set of strings that it accepts {0,1} 0,1q0 L(M) = All strings of 0s and 1s! The Language of Machine M q0 q1 0 0 1 1 L(M) = { w | w has an even number of 1s}
  • 3. An alphabet ! is a finite set (e.g., ! = {0,1}) A string over ! is a finite-length sequence of elements of !. The set of all strings over ! is denoted by !*. For x a string, |x| is the length of x The unique string of length 0 will be denoted by " and will be called the empty or null string Notation A language over ! is a set of strings over ! Q is the set of states ! is the alphabet " : Q # ! # Q is the transition function q0 $ Q is the start state F % Q is the set of accept states A finite automaton is a 5-tuple M = (Q, !, ", q0, F) L(M) = the language of machine M = set of all strings machine M accepts Q = {q0, q1, q2, q3} ! = {0,1} " : Q # ! " Q transition function q0 $ Q is start state F = {q1, q2} % Q accept states M = (Q, !, ", q0, F) where " 0 1 q0 q0 q1 q1 q2 q2 q2 q3 q2 q3 q0 q2 q2 0 0,1 00 1 1 1 q0 q1 q3 M Input String Result aba aabb aabba & b b a b a a a b a b Accept Reject Accept Accept “ABA” The Automaton
  • 4. What machine accepts this language? L = all strings in {a,b}* that contain at least one a b a,b a What machine accepts this language? L = strings with an odd number of b’s and any number of a’s a a b b What is the language accepted by this machine? L = any string ending with a b a b b a What is the language accepted by this machine? b a,b a b a L(M) = any string with at least two a’s
  • 5. What machine accepts this language? L = any string with an a and a b a b b a a a,b b What machine accepts this language? L = strings with an even number of ab pairs a b b a a b a b q q00 1 0 1 q0 q001 0 0 1 0,1 Build an automaton that accepts all and only those strings that contain 001 L = all strings containing ababb as a consecutive substring q qab b b qa qaba a b a a qabab b qababb b a,b aa Invariant: I am state s exactly when s is the longest suffix of the input (so far) forming a prefix of ababb.
  • 6. Input: Text T of length t, string S of length n The “Grep” Problem Problem: Does string S appear inside text T? a1, a2, a3, a4, a5, …, at Naïve method: Cost: Roughly nt comparisons Automata Solution Build a machine M that accepts any string with S as a consecutive substring Feed the text to M Cost: As luck would have it, the Knuth, Morris, Pratt algorithm builds M quickly t comparisons + time to build M Grep Coke Machines Thermostats (fridge) Elevators Train Track Switches Lexical Analyzers for Parsers Real-life Uses of DFAs A language is regular if it is recognized by a deterministic finite automaton L = { w | w contains 001} is regular L = { w | w has an even number of 1s} is regular
  • 7. Union Theorem Given two languages, L1 and L2, define the union of L1 and L2 as L1 ' L2 = { w | w $ L1 or w $ L2 } Theorem: The union of two regular languages is also a regular language Theorem: The union of two regular languages is also a regular language Proof Sketch: Let M1 = (Q1, !, "1, q0, F1) be finite automaton for L1 and M2 = (Q2, !, "2, q0, F2) be finite automaton for L2 We want to construct a finite automaton M = (Q, !, ", q0, F) that recognizes L = L1 ' L2 1 2 Idea: Run both M1 and M2 at the same time! Q = pairs of states, one from M1 and one from M2 = { (q1, q2) | q1 $ Q1 and q2 $ Q2 } = Q1 # Q2 Theorem: The union of two regular languages is also a regular language q0 q1 0 0 1 1 p0 p1 1 1 0 0
  • 8. q0,p0 q1,p0 1 1 q0,p1 q1,p1 1 1 0 0 0 0 Automaton for Union q0,p0 q1,p0 1 1 q0,p1 q1,p1 1 1 0 0 0 0 Automaton for Intersection Theorem: The union of two regular languages is also a regular language Corollary: Any finite language is regular The Regular Operations Union: A ' B = { w | w $ A or w $ B } Intersection: A ( B = { w | w $ A and w $ B } Negation: ¬A = { w | w ) A } Reverse: AR = { w1 …wk | wk …w1 $ A } Concatenation: A * B = { vw | v $ A and w $ B } Star: A* = { w1 …wk | k ! 0 and each wi $ A }
  • 9. Regular Languages Are Closed Under The Regular Operations We have seen part of the proof for Union. The proof for intersection is very similar. The proof for negation is easy. Are all languages regular? i.e., a bunch of a’s followed by an equal number of b’s Consider the language L = { anbn | n > 0 } No finite automaton accepts this language Can you prove this? anbn is not regular. No machine has enough states to keep track of the number of a’s it might encounter
  • 10. That is a fairly weak argument Consider the following example… L = strings where the # of occurrences of the pattern ab is equal to the number of occurrences of the pattern ba Can’t be regular. No machine has enough states to keep track of the number of occurrences of ab M accepts only the strings with an equal number of ab’s and ba’s! b b a b a a a b a b Let me show you a professional strength proof that anbn is not regular…
  • 11. Pigeonhole principle: Given n boxes and m > n objects, at least one box must contain more than one object Letterbox principle: If the average number of letters per box is x, then some box will have at least x letters (similarly, some box has at most x) Theorem: L= {anbn | n > 0 } is not regular Proof (by contradiction): Assume that L is regular Then there exists a machine M with k states that accepts L For each 0 + i + k, let Si be the state M is in after reading ai ,i,j + k such that Si = Sj, but i - j M will do the same thing on aibi and ajbi But a valid M must reject ajbi and accept aibi Advertisement You can learn much more about these creatures in the FLAC course. Formal Languages, Automata, and Computation • There is a unique smallest automaton for any regular language • It can be found by a fast algorithm. Deterministic Finite Automata • Definition • Testing if they accept a string • Building automata Regular Languages • Definition • Closed Under Union, Intersection, Negation • Using Pigeonhole Principle to show language not regular Here’s What You Need to Know…