SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Formal Definition of Computation
Let M = (Q, ∑ , δ, q0, F) be a finite automaton
and let w = w1w2.....wn be a string where
each wi is a member of the alphabet ∑. Then
M accepts w if a sequence of states r0, r1, ….,rn In
Q exists with three conditions:
1- r0= q0,
2- δ(ri, wi+1)=ri+1, for i=0,...,n-1, and
3- rn∈ F
Cont.






Condition 1 says that the machine starts in
the start state.
Condition 2 says that the machine goes
from state to another according to the
transition function
Condition 3 says that the machine accepts
its input if it ends up in an accept state. We
say that M recognizes language A if

A = {w | M accepts w}
Regular Language


Definition:

A language is called a regular language if
some finite automaton recognizes it.
See example 1.17 p. 41
Designing Finite Automata






Just like artwork, design is a creative
process...
Suppose you are given some language,
and you want to design a FA that
recognizes it...pretend that you are the
machine!
Take symbols, one by one, and and after
each symbol, you should decide whether
the string so far is in the language or not.
Designing Finite Automata –Cont.




What if the string is from earth to moon
long? And your memory (as a FA) is like a
sheet of paper? Worry-less, you will have
to memorize the crucial info only, like:
“What's my status now?”
Example: suppose: alphabet = {0,1}, and
that the language consists of all strings
with an odd number of 1s. You want to
construct a FA E1 to recognize this
language
Designing Finite Automata –Cont.
By pretending that you're the FA, get the
symbols (1 by 1), do you need to
remember all the string? No! Just
remembering the number of 1s so far is
even or not is enough, so that if next is 0,
don't change, if 1, change!


Therefore, you have 2 states, say: q odd, qeven.
Designing Finite Automata –Cont.




Next, assign transitions.
Assign a start state (qeven) in our example,
since no symbol has been entered so far
(0) and 0 is even.



What about Final state (accept)?



See example 1.21 - P.43
Regular Operations


We use them to study properties of regular
languages, those properties will help us
develop a toolbox that will include ways of
proving certain other languages are
nonregular (i.e. beyond the capability of
FA)
Regular Operations


If A and B are languages, then:



Union: A∪B = {x|x ∈ A or x ∈ B}







Concatenation: A ○ B = {xy | x ∈ A and y ∈
B}
Star: A* = {x1x2....xk | k>=0 and each xi∈A}
The star operation is unary operation (on 1
language) while the union and conc. are
binary operations
Regular Operations – cont.
Let ∑ = {a,b,....,z}, if A = {good, bad}, and B = {boy,
girl} the:

A ∪ B = {good, bad, boy, girl}
A ○ B = {goodboy, goodgirl, badboy, badgirl}
A*= {ε, good, bad, goodgood, badbad, badgood,
goodgoodgood, goodgoodbad, etc.....}
Regular Operations Cont.


Closed under multiplication:

example, if x and y are two numbers from N,
then x*y results a number also from N.




But N is not closed under division,
because x/y may result a number which
isn't member of N, ex. X=1, y=2, x/y=1/2
which isn't member of N
Please read theorems 1.25, 1.26 p.45, 46
Nondeterminism


DFA vs. NFA:

DFA has exactly one exiting transition arrow
for each symbol in the alphabet, NFA
violets that.




DFA uses symbols from alphabet only for
arrow labels, NFA may use others, such as
ε.
What will happen if a state has two arrows
for same input? Or if input is ε?
NFA
0,1
q1

0,1
1

q2

0,ε

q3

1

q
q4
4


Examples:

1.30, 1.33, 1.35 P: 51-53
Formal definition of NFA






Similar to DFA, the NFA has the 5-tuple,
yet the difference is in δ (The Transition
Function)
In DFA, δ takes a state and an input
symbol and produces the next state.
In NFA, δ takes a state and an an input
symbol OR the empty string and produces
the set of possible next states.
Cont.
Therefore, point 3 of the tuple would be as:
δ : Q X ∑ε → P(Q), where
∑ε is the result of ∑ ∪ ε
Example
The formal definition of N1 (slide 13):
1- Q = {q1,q2,q3,q4}
2- ∑ = {0,1}
3- δ is given as:
4- q1 =start state
5- F ={q4}

0

1

ε

q1

{q1}

{q1,q2}

Ф

q2

{q3}

Ф

{q3}

q3

Ф

{q4}

Ф

q4

{q4}

{q4}

Ф
Reading


Every NFA has an equivalent DFA...

To prove, read P.54- P.58


Based on your previous reading (P.45),
read Closure under the regular operations
(P.58-63). Which is similar to, yet easier
than example P.45.
Regular Expressions




In math, we use + and x to build up
expressions like: (5+3)x4 (Gives 32)
Similarly, we use∪ and * to build up

expressions describing languages, called
Regular Expressions (RegEx):
(0 ∪ 1)0* … (Gives a language)

What does (0 ∪ 1)0* mean?


It's a language consisting of all strings starting
with a 0 or 1 followed by any number of 0s.
RegEx – Cont.
(0 ∪ 1)0* is:
- (0 ∪ 1) = ({0}∪{1}) = {0,1}
- 0* means {0}*, means a language consisting of of any
number of 0s.
The concatenation between (0 ∪ 1) and 0* is a
shorthand for for (0 ∪ 1) ○ 0*




Applications of RegEx: many, Grep (text-search)in
Unix and Linux, Perl, C++, text editors etc....
In C++, you can use regex r("(+|-)?[[:digit:]]+");, but
why?
Regex- Example
(0 ∪ 1)* = the language consisting of all possible
strings of 0s and 1s.
If ∑ ={0,1}, then ∑ is a shorthand for (0 ∪ 1).




Generally, if ∑ is any alphabet, the regex ∑
describes the language consisting of all strings of
length 1 over the alphabet, and ∑* describes the
language consisting of all strings over the
alphabet.
∑*1 is the language that contains all strings that
end with 1
Regex- Example-cont.


The language (0∑*) ∪ (∑*1) consists of all

strings that either start with a 0 or end with a 1.
* similar to mathematical precedence ( x before +
for example), in regex, * is done first ,then
concatenation, finally the union. Unless
parentheses are used.
Formal Definition of regex


We say that R is a regex if R:

1. a for some a in the alphabet
2. ε,
3. ᶲ
4. (R1 ∪ R2)
5. (R1 ○ R2)
6. (R1*), where R1 is a regex

Weitere ähnliche Inhalte

Was ist angesagt?

3.1 intro toautomatatheory h1
3.1 intro toautomatatheory  h13.1 intro toautomatatheory  h1
3.1 intro toautomatatheory h1Rajendran
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theoryNYversity
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationPrafullMisra
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture NotesFellowBuddy.com
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfadeepinderbedi
 
Automata
AutomataAutomata
AutomataGaditek
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
NFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikNFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikMudsaraliKhushik
 
Regular expressions and languages pdf
Regular expressions and languages pdfRegular expressions and languages pdf
Regular expressions and languages pdfDilouar Hossain
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 
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)Mohammad Ilyas Malik
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler designRiazul Islam
 

Was ist angesagt? (20)

Automata Theory
Automata TheoryAutomata Theory
Automata Theory
 
3.1 intro toautomatatheory h1
3.1 intro toautomatatheory  h13.1 intro toautomatatheory  h1
3.1 intro toautomatatheory h1
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theory
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture Notes
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfa
 
Automata
AutomataAutomata
Automata
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
NFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikNFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushik
 
Minimizing DFA
Minimizing DFAMinimizing DFA
Minimizing DFA
 
Regular expressions and languages pdf
Regular expressions and languages pdfRegular expressions and languages pdf
Regular expressions and languages pdf
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Ch3
Ch3Ch3
Ch3
 
Finite automata
Finite automataFinite automata
Finite automata
 
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)
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
Finite automata
Finite automataFinite automata
Finite automata
 

Andere mochten auch

Andere mochten auch (13)

Theory of computation Lec6
Theory of computation Lec6Theory of computation Lec6
Theory of computation Lec6
 
Music advert analysis rihanna
Music advert analysis rihannaMusic advert analysis rihanna
Music advert analysis rihanna
 
Presentacion 4 pre teen 2 a.
Presentacion 4 pre teen 2 a.Presentacion 4 pre teen 2 a.
Presentacion 4 pre teen 2 a.
 
Theory of computation Lec2
Theory of computation Lec2Theory of computation Lec2
Theory of computation Lec2
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
Deterministic Finite Automata
Deterministic Finite AutomataDeterministic Finite Automata
Deterministic Finite Automata
 
declamation piece for high school, english TRAGEDY
declamation piece for high school, english TRAGEDYdeclamation piece for high school, english TRAGEDY
declamation piece for high school, english TRAGEDY
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Dfa vs nfa
Dfa vs nfaDfa vs nfa
Dfa vs nfa
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Declamation pieces
Declamation piecesDeclamation pieces
Declamation pieces
 

Ähnlich wie Theory of Computation - Lectures 4 and 5

Automata
AutomataAutomata
AutomataGaditek
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdfImranBhatti58
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghggggggggggggggggggggggggggggggggggadugnanegero
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxssuser039bf6
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysisraosir123
 
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
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaRushabh2428
 

Ähnlich wie Theory of Computation - Lectures 4 and 5 (20)

Automata
AutomataAutomata
Automata
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdf
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggg
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
rs1.ppt
rs1.pptrs1.ppt
rs1.ppt
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
 
draft
draftdraft
draft
 
Unit ii
Unit iiUnit ii
Unit ii
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptx
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
PART A.doc
PART A.docPART A.doc
PART A.doc
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
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
 
unit 2 part b.docx
unit 2 part b.docxunit 2 part b.docx
unit 2 part b.docx
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
Re1 (3)
Re1 (3)Re1 (3)
Re1 (3)
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 

Mehr von Dr. Maamoun Ahmed

Minimum spanning trees – prim's and kruskal's algorithms
Minimum spanning trees – prim's and kruskal's algorithmsMinimum spanning trees – prim's and kruskal's algorithms
Minimum spanning trees – prim's and kruskal's algorithmsDr. Maamoun Ahmed
 
Finding Minimum Spanning Tree using Prim's Algorithm - Matrix approach
Finding Minimum Spanning Tree using Prim's Algorithm - Matrix approachFinding Minimum Spanning Tree using Prim's Algorithm - Matrix approach
Finding Minimum Spanning Tree using Prim's Algorithm - Matrix approachDr. Maamoun Ahmed
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsDr. Maamoun Ahmed
 
Theory of Computation - Lectures 6 & 7
Theory of Computation - Lectures 6 & 7Theory of Computation - Lectures 6 & 7
Theory of Computation - Lectures 6 & 7Dr. Maamoun Ahmed
 
Theory of Computation - Lecture 3
Theory of Computation - Lecture 3Theory of Computation - Lecture 3
Theory of Computation - Lecture 3Dr. Maamoun Ahmed
 
Theory of Computation - Strings and Languages and Proofs (Lecture 2)
Theory of Computation  - Strings and Languages and Proofs (Lecture 2)Theory of Computation  - Strings and Languages and Proofs (Lecture 2)
Theory of Computation - Strings and Languages and Proofs (Lecture 2)Dr. Maamoun Ahmed
 

Mehr von Dr. Maamoun Ahmed (7)

A* - Astar - A-Star
A* - Astar - A-StarA* - Astar - A-Star
A* - Astar - A-Star
 
Minimum spanning trees – prim's and kruskal's algorithms
Minimum spanning trees – prim's and kruskal's algorithmsMinimum spanning trees – prim's and kruskal's algorithms
Minimum spanning trees – prim's and kruskal's algorithms
 
Finding Minimum Spanning Tree using Prim's Algorithm - Matrix approach
Finding Minimum Spanning Tree using Prim's Algorithm - Matrix approachFinding Minimum Spanning Tree using Prim's Algorithm - Matrix approach
Finding Minimum Spanning Tree using Prim's Algorithm - Matrix approach
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relations
 
Theory of Computation - Lectures 6 & 7
Theory of Computation - Lectures 6 & 7Theory of Computation - Lectures 6 & 7
Theory of Computation - Lectures 6 & 7
 
Theory of Computation - Lecture 3
Theory of Computation - Lecture 3Theory of Computation - Lecture 3
Theory of Computation - Lecture 3
 
Theory of Computation - Strings and Languages and Proofs (Lecture 2)
Theory of Computation  - Strings and Languages and Proofs (Lecture 2)Theory of Computation  - Strings and Languages and Proofs (Lecture 2)
Theory of Computation - Strings and Languages and Proofs (Lecture 2)
 

Kürzlich hochgeladen

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
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
 
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 ConsultingTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
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
 
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
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Kürzlich hochgeladen (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
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
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
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 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
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
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Theory of Computation - Lectures 4 and 5

  • 1. Formal Definition of Computation Let M = (Q, ∑ , δ, q0, F) be a finite automaton and let w = w1w2.....wn be a string where each wi is a member of the alphabet ∑. Then M accepts w if a sequence of states r0, r1, ….,rn In Q exists with three conditions: 1- r0= q0, 2- δ(ri, wi+1)=ri+1, for i=0,...,n-1, and 3- rn∈ F
  • 2. Cont.    Condition 1 says that the machine starts in the start state. Condition 2 says that the machine goes from state to another according to the transition function Condition 3 says that the machine accepts its input if it ends up in an accept state. We say that M recognizes language A if A = {w | M accepts w}
  • 3. Regular Language  Definition: A language is called a regular language if some finite automaton recognizes it. See example 1.17 p. 41
  • 4. Designing Finite Automata    Just like artwork, design is a creative process... Suppose you are given some language, and you want to design a FA that recognizes it...pretend that you are the machine! Take symbols, one by one, and and after each symbol, you should decide whether the string so far is in the language or not.
  • 5. Designing Finite Automata –Cont.   What if the string is from earth to moon long? And your memory (as a FA) is like a sheet of paper? Worry-less, you will have to memorize the crucial info only, like: “What's my status now?” Example: suppose: alphabet = {0,1}, and that the language consists of all strings with an odd number of 1s. You want to construct a FA E1 to recognize this language
  • 6. Designing Finite Automata –Cont. By pretending that you're the FA, get the symbols (1 by 1), do you need to remember all the string? No! Just remembering the number of 1s so far is even or not is enough, so that if next is 0, don't change, if 1, change!  Therefore, you have 2 states, say: q odd, qeven.
  • 7. Designing Finite Automata –Cont.   Next, assign transitions. Assign a start state (qeven) in our example, since no symbol has been entered so far (0) and 0 is even.  What about Final state (accept)?  See example 1.21 - P.43
  • 8. Regular Operations  We use them to study properties of regular languages, those properties will help us develop a toolbox that will include ways of proving certain other languages are nonregular (i.e. beyond the capability of FA)
  • 9. Regular Operations  If A and B are languages, then:  Union: A∪B = {x|x ∈ A or x ∈ B}    Concatenation: A ○ B = {xy | x ∈ A and y ∈ B} Star: A* = {x1x2....xk | k>=0 and each xi∈A} The star operation is unary operation (on 1 language) while the union and conc. are binary operations
  • 10. Regular Operations – cont. Let ∑ = {a,b,....,z}, if A = {good, bad}, and B = {boy, girl} the: A ∪ B = {good, bad, boy, girl} A ○ B = {goodboy, goodgirl, badboy, badgirl} A*= {ε, good, bad, goodgood, badbad, badgood, goodgoodgood, goodgoodbad, etc.....}
  • 11. Regular Operations Cont.  Closed under multiplication: example, if x and y are two numbers from N, then x*y results a number also from N.   But N is not closed under division, because x/y may result a number which isn't member of N, ex. X=1, y=2, x/y=1/2 which isn't member of N Please read theorems 1.25, 1.26 p.45, 46
  • 12. Nondeterminism  DFA vs. NFA: DFA has exactly one exiting transition arrow for each symbol in the alphabet, NFA violets that.   DFA uses symbols from alphabet only for arrow labels, NFA may use others, such as ε. What will happen if a state has two arrows for same input? Or if input is ε?
  • 15. Formal definition of NFA    Similar to DFA, the NFA has the 5-tuple, yet the difference is in δ (The Transition Function) In DFA, δ takes a state and an input symbol and produces the next state. In NFA, δ takes a state and an an input symbol OR the empty string and produces the set of possible next states.
  • 16. Cont. Therefore, point 3 of the tuple would be as: δ : Q X ∑ε → P(Q), where ∑ε is the result of ∑ ∪ ε
  • 17. Example The formal definition of N1 (slide 13): 1- Q = {q1,q2,q3,q4} 2- ∑ = {0,1} 3- δ is given as: 4- q1 =start state 5- F ={q4} 0 1 ε q1 {q1} {q1,q2} Ф q2 {q3} Ф {q3} q3 Ф {q4} Ф q4 {q4} {q4} Ф
  • 18. Reading  Every NFA has an equivalent DFA... To prove, read P.54- P.58  Based on your previous reading (P.45), read Closure under the regular operations (P.58-63). Which is similar to, yet easier than example P.45.
  • 19. Regular Expressions   In math, we use + and x to build up expressions like: (5+3)x4 (Gives 32) Similarly, we use∪ and * to build up expressions describing languages, called Regular Expressions (RegEx): (0 ∪ 1)0* … (Gives a language) What does (0 ∪ 1)0* mean?  It's a language consisting of all strings starting with a 0 or 1 followed by any number of 0s.
  • 20. RegEx – Cont. (0 ∪ 1)0* is: - (0 ∪ 1) = ({0}∪{1}) = {0,1} - 0* means {0}*, means a language consisting of of any number of 0s. The concatenation between (0 ∪ 1) and 0* is a shorthand for for (0 ∪ 1) ○ 0*   Applications of RegEx: many, Grep (text-search)in Unix and Linux, Perl, C++, text editors etc.... In C++, you can use regex r("(+|-)?[[:digit:]]+");, but why?
  • 21. Regex- Example (0 ∪ 1)* = the language consisting of all possible strings of 0s and 1s. If ∑ ={0,1}, then ∑ is a shorthand for (0 ∪ 1).   Generally, if ∑ is any alphabet, the regex ∑ describes the language consisting of all strings of length 1 over the alphabet, and ∑* describes the language consisting of all strings over the alphabet. ∑*1 is the language that contains all strings that end with 1
  • 22. Regex- Example-cont.  The language (0∑*) ∪ (∑*1) consists of all strings that either start with a 0 or end with a 1. * similar to mathematical precedence ( x before + for example), in regex, * is done first ,then concatenation, finally the union. Unless parentheses are used.
  • 23. Formal Definition of regex  We say that R is a regex if R: 1. a for some a in the alphabet 2. ε, 3. ᶲ 4. (R1 ∪ R2) 5. (R1 ○ R2) 6. (R1*), where R1 is a regex