SlideShare une entreprise Scribd logo
1  sur  12
WELCOME TO A
JOURNEY TO
CS419

Dr. Hussien Sharaf
Computer Science Department

dr.sharaf@from-masr.com
DEFINITION OF A LANAGUAGE “L”
∑ is the set of alphabets
*
1. Let ∑ ={x}, Then L = ∑
*
In RE, we write x
*
2. Let ∑ ={x, y}, Then L = ∑
*
In RE, we write (x+y)
3. Kleene’s star “*” means any combination of
letters of length zero or more.
Note: Please study the appendix at the end of
the lecture
Dr. Hussien M. Sharaf

2
RE RULES
Given an alphabet ∑, the set of regular expressions is
defined by the following rules.
1.

2.

For every letter in ∑, the letter written in bold is a
regular expression. Λ- lamda or ε-epsilon is a
regular expression. Λ or ε means an empty letter.
If r1 and r2 are regular expressions, then so are:
1.
2.
3.
4.

(r1)
r1 r2
r1+r2
r1* and also r2*

NOTE 1: r1+ is not a RE
NOTE 2: spaces are ignored as long as they are not included in ∑
3.

Nothing else is a regular expression.

Dr. Hussien M. Sharaf

3
RE-10.1
Example
∑ ={a, b}, What does L describe?
*
*
- L = (a+b) a(a+b)


Any string of a's and b's

Any string of a's and b's
Single a

- Give examples for words in L
{a ab aab bab abb …..}

Dr. Hussien M. Sharaf

4
RE-10.2

abbaab can be parsed in 3 ways
a bbaab
Λ a bbaab

Dr. Hussien M. Sharaf

abba a b

abb a ab
abb

a

ab

abba

a

b

5
RE-11
Example
∑ ={a, b}
- Formally describe all words with at least two a's.
1) L = b*ab*a(a + b)*
 Start with a jungle of b's (or no b's) until we find
the first a, then more b's (or no b's), then the
second a, then we finish up with anything.
- Give examples for words in L
{abbbabb aaaaa bbbabbbbabab…..}


Dr. Hussien M. Sharaf

6
RE-12
Example
∑ ={a, b}
- Formally describe all words with exactly two a's.
1) L = b*ab*ab*
- Give examples for words in L
{aab, baba, and bbbabbbab …..}
 To make the word aab, we let the first and second
b* become Λ and the last becomes b


Dr. Hussien M. Sharaf

7
RE-13.1
Example
∑ ={a, b}
- Formally describe all words with at least
one a and at least one b.
1) L = (a + b)*a(a + b)* b(a + b)*


= (anything) a(anything) b(anything)
But (a+b)*a(a+b)*b(a+b)* expresses all words except
words of the form some b’s (at least one) followed by
some a’s (at least one).
bb*aa*
Dr. Hussien M. Sharaf

8
RE-13.1
2) L =(a+b)*a(a+b)*b(a+b)* + bb*aa*
Thus: (a+b)*a(a+b)*b(a+b)* + (a+b)*b(a+b)*a(a+b)*
= (a+b)*a(a+b)*b(a+b)* + bb*aa*


Notice that it is necessary to write bb*aa*
because b*a* will admit words we do not
want, such as aaa.

Does this imply that
(a+b)*b(a+b)*a(a+b)*= bb*aa*??

False Left side includes the word aba, which
the
expression on the right side does not.
Dr. Hussien M. Sharaf

9
ASSIGNMENTS
1.
2.
3.

[One week] Solve Compilers-Sheet_0General.pdf
[One week] Solve Compilers_Sheet_1_RE.pdf
[Two weeks] Implement an email validator
using Python.
a.
b.
c.

Build a GUI using python Tkinter.
The GUI must include at least two labels, a TextBox
and a Button.
The user is given a message on a label stating
whether the email is a valid email or not.

Dr. Hussien M. Sharaf

10
DEADLINE
Thursday 28th of Feb is the deadline.
 No excuses.
 Don’t wait until last day.
 TAs can help you to the highest limit
within the next 3 days.


Dr. Hussien M. Sharaf

11
THANKS
Dr. Hussien M. Sharaf

12

Contenu connexe

Tendances (20)

Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Cs419 lec6 lexical analysis using nfa
Cs419 lec6   lexical analysis using nfaCs419 lec6   lexical analysis using nfa
Cs419 lec6 lexical analysis using nfa
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Regular expression
Regular expressionRegular expression
Regular expression
 
draft
draftdraft
draft
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Discrete mathematics presentation
Discrete mathematics presentationDiscrete mathematics presentation
Discrete mathematics presentation
 
Automata definitions
Automata definitionsAutomata definitions
Automata definitions
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theory
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
 
Theory of computation Lec1
Theory of computation Lec1Theory of computation Lec1
Theory of computation Lec1
 
FLAT Notes
FLAT NotesFLAT Notes
FLAT Notes
 

En vedette (16)

Cs419 lec12 semantic analyzer
Cs419 lec12  semantic analyzerCs419 lec12  semantic analyzer
Cs419 lec12 semantic analyzer
 
Cs419 lec8 top-down parsing
Cs419 lec8    top-down parsingCs419 lec8    top-down parsing
Cs419 lec8 top-down parsing
 
Cs419 lec9 constructing parsing table ll1
Cs419 lec9   constructing parsing table ll1Cs419 lec9   constructing parsing table ll1
Cs419 lec9 constructing parsing table ll1
 
Cs419 Compiler lec1&2 introduction
Cs419 Compiler lec1&2  introductionCs419 Compiler lec1&2  introduction
Cs419 Compiler lec1&2 introduction
 
Theory of Computer Science - Post Correspondence Problem
Theory of Computer Science - Post Correspondence ProblemTheory of Computer Science - Post Correspondence Problem
Theory of Computer Science - Post Correspondence Problem
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Cs419 lec10 left recursion and left factoring
Cs419 lec10   left recursion and left factoringCs419 lec10   left recursion and left factoring
Cs419 lec10 left recursion and left factoring
 
Infos2014
Infos2014Infos2014
Infos2014
 
Theory of computation Lec7 pda
Theory of computation Lec7 pdaTheory of computation Lec7 pda
Theory of computation Lec7 pda
 
theory of computation lecture 01
theory of computation lecture 01theory of computation lecture 01
theory of computation lecture 01
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Cs419 lec11 bottom-up parsing
Cs419 lec11   bottom-up parsingCs419 lec11   bottom-up parsing
Cs419 lec11 bottom-up parsing
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
Minimizing DFA
Minimizing DFAMinimizing DFA
Minimizing DFA
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 

Similaire à Cs419 lec4 lexical analysis using re

Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 
Handout Regular expression with examples and lecture
Handout Regular expression with examples  and lecture Handout Regular expression with examples  and lecture
Handout Regular expression with examples and lecture mariajan8
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
Theory of Automata Lesson 01
 Theory of Automata Lesson 01  Theory of Automata Lesson 01
Theory of Automata Lesson 01 hamzamughal39
 
Lesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptLesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptashja1
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 
Introduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 SolutionsIntroduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 SolutionsAshu
 
1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expressionSampath Kumar S
 

Similaire à Cs419 lec4 lexical analysis using re (20)

L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
regular expression
regular expressionregular expression
regular expression
 
Handout Regular expression with examples and lecture
Handout Regular expression with examples  and lecture Handout Regular expression with examples  and lecture
Handout Regular expression with examples and lecture
 
Lesson 04
Lesson 04Lesson 04
Lesson 04
 
Ch2 automata.pptx
Ch2 automata.pptxCh2 automata.pptx
Ch2 automata.pptx
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Theory of computation
Theory of computationTheory of computation
Theory of computation
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Theory of Automata Lesson 01
 Theory of Automata Lesson 01  Theory of Automata Lesson 01
Theory of Automata Lesson 01
 
Lesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptLesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.ppt
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
13000120020_A.pptx
13000120020_A.pptx13000120020_A.pptx
13000120020_A.pptx
 
Introduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 SolutionsIntroduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 Solutions
 
1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression
 
Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 
Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 

Plus de Arab Open University and Cairo University

Plus de Arab Open University and Cairo University (13)

File Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswerFile Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswer
 
Model answer of compilers june spring 2013
Model answer of compilers june spring 2013Model answer of compilers june spring 2013
Model answer of compilers june spring 2013
 
Model answer of exam TC_spring 2013
Model answer of exam TC_spring 2013Model answer of exam TC_spring 2013
Model answer of exam TC_spring 2013
 
Setup python with eclipse
Setup python with eclipseSetup python with eclipse
Setup python with eclipse
 
Compilers Final spring 2013 model answer
 Compilers Final spring 2013 model answer Compilers Final spring 2013 model answer
Compilers Final spring 2013 model answer
 
Compilers midterm spring 2013 model answer
Compilers midterm spring 2013   model answerCompilers midterm spring 2013   model answer
Compilers midterm spring 2013 model answer
 
Final Exam OS fall 2012-2013 with answers
Final Exam OS fall 2012-2013 with answersFinal Exam OS fall 2012-2013 with answers
Final Exam OS fall 2012-2013 with answers
 
CS215 - Lec 8 searching records
CS215 - Lec 8  searching recordsCS215 - Lec 8  searching records
CS215 - Lec 8 searching records
 
CS215 - Lec 7 managing records collection
CS215 - Lec 7  managing records collectionCS215 - Lec 7  managing records collection
CS215 - Lec 7 managing records collection
 
CS215 - Lec 6 record index
CS215 - Lec 6  record indexCS215 - Lec 6  record index
CS215 - Lec 6 record index
 
CS215 - Lec 5 record organization
CS215 - Lec 5  record organizationCS215 - Lec 5  record organization
CS215 - Lec 5 record organization
 
CS215 - Lec 4 single record organization
CS215 - Lec 4  single record organizationCS215 - Lec 4  single record organization
CS215 - Lec 4 single record organization
 
CS215 - Lec 2 file organization
CS215 - Lec 2   file organizationCS215 - Lec 2   file organization
CS215 - Lec 2 file organization
 

Dernier

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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
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
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
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...christianmathematics
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Dernier (20)

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"
 
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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
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
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
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
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
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...
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

Cs419 lec4 lexical analysis using re

  • 1. WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Computer Science Department dr.sharaf@from-masr.com
  • 2. DEFINITION OF A LANAGUAGE “L” ∑ is the set of alphabets * 1. Let ∑ ={x}, Then L = ∑ * In RE, we write x * 2. Let ∑ ={x, y}, Then L = ∑ * In RE, we write (x+y) 3. Kleene’s star “*” means any combination of letters of length zero or more. Note: Please study the appendix at the end of the lecture Dr. Hussien M. Sharaf 2
  • 3. RE RULES Given an alphabet ∑, the set of regular expressions is defined by the following rules. 1. 2. For every letter in ∑, the letter written in bold is a regular expression. Λ- lamda or ε-epsilon is a regular expression. Λ or ε means an empty letter. If r1 and r2 are regular expressions, then so are: 1. 2. 3. 4. (r1) r1 r2 r1+r2 r1* and also r2* NOTE 1: r1+ is not a RE NOTE 2: spaces are ignored as long as they are not included in ∑ 3. Nothing else is a regular expression. Dr. Hussien M. Sharaf 3
  • 4. RE-10.1 Example ∑ ={a, b}, What does L describe? * * - L = (a+b) a(a+b)  Any string of a's and b's Any string of a's and b's Single a - Give examples for words in L {a ab aab bab abb …..} Dr. Hussien M. Sharaf 4
  • 5. RE-10.2 abbaab can be parsed in 3 ways a bbaab Λ a bbaab Dr. Hussien M. Sharaf abba a b abb a ab abb a ab abba a b 5
  • 6. RE-11 Example ∑ ={a, b} - Formally describe all words with at least two a's. 1) L = b*ab*a(a + b)*  Start with a jungle of b's (or no b's) until we find the first a, then more b's (or no b's), then the second a, then we finish up with anything. - Give examples for words in L {abbbabb aaaaa bbbabbbbabab…..}  Dr. Hussien M. Sharaf 6
  • 7. RE-12 Example ∑ ={a, b} - Formally describe all words with exactly two a's. 1) L = b*ab*ab* - Give examples for words in L {aab, baba, and bbbabbbab …..}  To make the word aab, we let the first and second b* become Λ and the last becomes b  Dr. Hussien M. Sharaf 7
  • 8. RE-13.1 Example ∑ ={a, b} - Formally describe all words with at least one a and at least one b. 1) L = (a + b)*a(a + b)* b(a + b)*  = (anything) a(anything) b(anything) But (a+b)*a(a+b)*b(a+b)* expresses all words except words of the form some b’s (at least one) followed by some a’s (at least one). bb*aa* Dr. Hussien M. Sharaf 8
  • 9. RE-13.1 2) L =(a+b)*a(a+b)*b(a+b)* + bb*aa* Thus: (a+b)*a(a+b)*b(a+b)* + (a+b)*b(a+b)*a(a+b)* = (a+b)*a(a+b)*b(a+b)* + bb*aa*  Notice that it is necessary to write bb*aa* because b*a* will admit words we do not want, such as aaa. Does this imply that (a+b)*b(a+b)*a(a+b)*= bb*aa*?? False Left side includes the word aba, which the expression on the right side does not. Dr. Hussien M. Sharaf 9
  • 10. ASSIGNMENTS 1. 2. 3. [One week] Solve Compilers-Sheet_0General.pdf [One week] Solve Compilers_Sheet_1_RE.pdf [Two weeks] Implement an email validator using Python. a. b. c. Build a GUI using python Tkinter. The GUI must include at least two labels, a TextBox and a Button. The user is given a message on a label stating whether the email is a valid email or not. Dr. Hussien M. Sharaf 10
  • 11. DEADLINE Thursday 28th of Feb is the deadline.  No excuses.  Don’t wait until last day.  TAs can help you to the highest limit within the next 3 days.  Dr. Hussien M. Sharaf 11