SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theory
NYversity
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 

Tendances (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
 

En vedette

Presentacion 4 pre teen 2 a.
Presentacion 4 pre teen 2 a.Presentacion 4 pre teen 2 a.
Presentacion 4 pre teen 2 a.
missyanina
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 

En vedette (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
 

Similaire à Theory of Computation - Lectures 4 and 5

02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
raosir123
 
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
Srimatre K
 

Similaire à Theory of Computation - Lectures 4 and 5 (20)

Automata
AutomataAutomata
Automata
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdf
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggg
 
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
 
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)
 

Plus de 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)
 

Dernier

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
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
QucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
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
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
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...
 
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
 
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.
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
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...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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
 
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Ữ Â...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 

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