SlideShare a Scribd company logo
Regular Expressions
CSE 2233
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Languages
Regular Language:
– A language is called a regular language if some finite automaton(DFA) recognizes it.
– A language is regular if and only if some nondeterministic finite automaton(NFA) recognizes it.
– If a language is described by a regular expression(RE), then it is also regular.
2
NFA
DFA
RE
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Operations
▸ 3 operations are defined on languages called Regular Operations.
▸ Here, the name Regular Operations is just a name that has been chosen for these 3 operations.
▸ Regular Operations are used to study properties of the Regular Languages.
Definition:
Let Σ be an alphabet and A,B ⊆ Σ* be languages. Then the regular operations are as follows:
 Union: The language A⋃B ⊆ Σ* is defined as, A⋃B = { w | w ∈ A or w ∈ B }
 Concatenation: The language AB ⊆ Σ* is defined as, AB = { wx | w ∈ A and x ∈ B }
 Kleene star/ Star: The language A* is defined as, A* = { x1x2 … … xk | k≥0 and each xi ∈ A }
3
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Operations - Example
Let,
Alphabet Σ = { a, b, c, … … … , z }
Language A = { good, bad } ⊆ Σ*
Language B = { boy, girl } ⊆ Σ*
Then,
A⋃B = { good, bad, boy, girl }
AB = { goodboy, goodgirl, badboy, badgirl }
A* = { 𝜀, good, bad, goodgood, goodbad, badgood, badbad, goodgoodgood, goodgoodbad, … … }
4
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Languages – Closure Property
▸ The regular languages are closed with respect to the regular operations:
if A, B ⊆ Σ* are regular languages, then the languages A⋃B, AB, and A* are also regular.
▸ There are many other operations on languages aside from the regular operations under which the
regular languages are also closed.
 Subtraction:
The language AB ⊆ Σ* is defined as, AB = { w | w ∈ A and w ∉ B } = A⋂ഥB
 Complement:
The language ഥA ⊆ Σ* is defined as, ഥA = { w | w ∈ Σ* and w ∉ A } = Σ*A
 Intersection:
The language A⋂B ⊆ ∑* is defined as, A⋂B = { w | w ∈ A and w ∈ B } = ҧ𝐴 ∪ ത𝐵
 Reverse:
The language AR ⊆ Σ* is defined as, AR = { wk wk-1 … … w2 w1 | w=w1w2 … … wk ∈ A }
5
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Expressions
Arithmetic Expressions:
▸ We use the operations + and x to build up expressions such as (5+3)x4
▸ The value of arithmetic expression is the number 32.
Regular Expression:
▸ We use regular operations to build up expressions describing languages called Regular Expressions.
▸ The value of regular expression is a language.
▸ For example, (0⋃1)0*
Note:
REs have an important role in computer science applications. It provides powerful methods to describe
different string patterns in UNIX commands, modern programming languages, text editors etc.
6
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Expressions – Definition
Regular Expression:
R is a regular expression if R is
▸ a for some a in the alphabet Σ,
▸ 𝜀,
▸ 𝜙,
▸ (R1 ⋃ R2), where R1 and R2 are regular expressions,
▸ (R1 o R2), where R1 and R2 are regular expressions, or
▸ (𝑅1
∗
), where R1 is a regular expression.
7
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Regular Expressions – Precedence Order
8
Precedence of Regular Operations:
1. Parentheses
2. Star
3. Concatenation
4. Union
So according to the precedence sequence: (ab U a)* = ( ( (a) (b) ) U ( a ) ) *
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
RE – Practices
9
Language, L(R) Regular Expression
{ w | w contains a single 1 } 0* 1 0*
{ w | w consists of exactly three 1’s } 0* 1 0* 1 0* 1 0*
{ w | w has at least a single 1 } (0 | 1)* 1 (0 | 1)*
{ w | w contains at least three 1’s } (0 | 1)* 1 (0 | 1)* 1 (0 | 1)* 1 (0 | 1)*
{ w | w has at most one 1 } 0* | 0* 1 0*
{ w | w contains an even number of 1’s } (0* 1 0* 1 0*)* 0*
{ w | the number of 1’s withing w can be evenly divided by 3 } (0* 1 0* 1 0* 1 0* )* 0*
{ w | w is a string of even length } (ΣΣ)*, here Σ = (0 | 1)
{ w | the length of w is a multiple of 3 } (ΣΣΣ)*, here Σ = (0 | 1)
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
RE – Practices
10
Language, L(R) Regular Expression
{ w | w starts with 101 } 101 (0 | 1)*
{ w | w contains the string 001 as a substring } (0 | 1)* 001 (0 | 1)*
{ w | w ends with 3 consecutive 1’s } (0 | 1)* 111
{ w | w doesn’t end with 11 } 𝜀 | 0 | 1 | (0 | 1)* (00 | 01 | 10)
{ w | w ends with an even nonzero number of 0’s } ( (0 | 1)* 1 | 𝜀 ) 00 (00)*
{ w | w starts and ends with the same symbol } 0 | 1 | 0Σ*0 | 1Σ*1, here Σ = (0 | 1)
{ w | w has at least 3 characters and the 3rd character is 0 } (0 | 1) (0 | 1) 0 (0 | 1)*
{ w | every zero in w is followed by at least one 1 } 1* (01+)*
{ w | w consists of alternating zeros and ones } (1 | 𝜀) (01)* (0 | 𝜀)
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
RE – Practices
11
Language, L(R) Regular Expression
{ 01, 10 } 01 | 10
01* | 1* (0 | 𝜀) 1*
{ 𝜀, 0, 1, 01 } (0 | 𝜀) (1 | 𝜀)
𝜙 R𝜙
{ 𝜀 } 𝜙*
{ w | w starts with 0 and has odd length or, starts with
1 and has even length }
0 ( (0 | 1) (0 | 1) )* | 1 (0 | 1) ( (0 | 1) (0 | 1) )*
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
RE  NFA
▸ R = a for some a ∈ Σ. Then L(R) = { a }, and the following NFA recognizes L(R)
▸ R = 𝜀 . Then L(R) = { 𝜀 } and the following NFA recognizes L(R)
▸ R = 𝜙 . Then L(R) = 𝜙, and the following NFA recognizes L(R)
▸ R = R1 U R2 , so L(R) = L(R1) U L(R2) = NFA1 recognizes L(R1) U NFA2 recognizes L(R2)
▸ R = R1 o R2 = R1R2 = = L(R1) o L(R2) = NFA1 recognizes L(R1) o NFA2 recognizes L(R2)
▸ R = R1
* = L(R1)* = ( NFA1 recognizes L(R1) )*
12
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
RE  NFA : Example 1
Convert the following RE to equivalent NFA:
(ab U a)*
13
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
RE  NFA : Practices
14
▸ ( a U b ) * a b a
▸ ( 0 U 1 ) * 0 0 0 ( 0 U 1 )* = Σ* 0 0 0 Σ* where Σ = 0, 1 = 0 U 1
▸ ( ( ( 0 0 )* ( 1 1 ) ) U 0 1 ) *
▸ ( 0 1 U 0 0 1 U 0 1 0 ) *
▸ a ( a b b ) * U b
▸ a+ U ( a b ) +
▸ ( a U b+ ) a+ b+ [ Hint: replace a+ with (a a*) ]
▸ 1* ( 0 1+)*
▸ ( Σ Σ Σ ) *
▸ 0 Σ* 0 U 1 Σ* 1 U 0 U 1
▸ 𝜙*
▸ ( 0 U 𝜀 ) 1*
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
DFA  GNFA  RE
15
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Steps to follow:
GNFA
▸ A GNFA is a nondeterministic finite automaton(NFA) in which each
transition is labeled with a regular expression over the alphabet set
instead of only members of the alphabet or 𝜀.
▸ A single initial state with all possible outgoing transitions and no
incoming transitions.
▸ A single final state without outgoing transitions but all possible
incoming transitions. The accept state is not the same as the start
state.
▸ A single transition between every two states, including self loops.
16
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
GNFA – Formal Definition
A generalized nondeterministic finite automaton is a 5 tuple,
(Q, Σ, 𝛿, qstart, qaccept ), where
▸ Q is the finite set of states
▸ Σ is the input alphabet
▸ 𝛿: ( Q - {qaccept} ) x ( Q - {qstart} )  ℛ is the transition function
[if you travel from state a 𝜖 ( Q - {qaccept} ) to state b 𝜖 ( Q - {qstart} ) then
this relation will generate ℛ regular expression ]
▸ qstart is the start state and
▸ qaccept is the accept state
17
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
GNFA – State Minimization Rule
18
Removing qrip state,
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
DFA  GNFA : Steps to Follow
19
▸ Add a new start state with an 𝜀 arrow to the old start state
▸ Add a new accept state with 𝜀 arrows from the old accept states to this new accept state
▸ If any arrows have multiple labels, replace each with a single arrow whose label is the union of the
previous labels
▸ Add arrows labeled 𝜙 between states that had no arrows. [better no to show this in the diagram, for
simplicity]
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
CONVERT(G):
1. Let k be the number of states of G.
2. If k=2, then G must consist of a start state, an accept state, and a single arrow connecting them and
labeled with a regular expression R
— Return the expression R.
3. If k>2, we select any state qrip ∈ Q different from qstart and qaccept and let G’ be the GNFA (Q’, Σ, 𝛿’, qstart,
qaccept), where
Q’ = Q - {qrip}
and for any qi ∈ Q’–{qaccept} and any qj ∈ Q’–{qstart}, let
𝛿’(qi, qj) = (R1) (R2)*(R3) U (R4)
for R1 = 𝛿(qi, qrip), R2 = 𝛿(qrip, qrip), R3 = 𝛿(qrip, qj), and R4 = 𝛿(qi, qj)
4. Compute CONVERT(G’) and return this value.
GNFA  RE : Algorithm
20
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
GNFA  RE : Removing State 2
21
Here, 2 is associated with states 1 and a. All possible combinations are (1,1), (1,a), (a,a), (a,1). But there
will be no outgoing from a, so no need to consider (a,a) and (a,1) states.
For (1,1), R = a U (b (aUb)* 𝜙)) = a
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
GNFA  RE : Removing State 2
22
Here, 2 is associated with states 1 and a. All possible combinations are (1,1), (1,a), (a,a), (a,1). But there
will be no outgoing from a, so no need to consider (a,a) and (a,1) states.
For (1,a), R = 𝜙 U (b (aUb)* 𝜀) = b(aUb)*
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
GNFA  RE : Removing State 1
23
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
DFA  GNFA  RE : Example 2
24
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
DFA  GNFA  RE : Practices
25
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Practice 1 Practice 2
26
THANKS!
Any questions?
You can find me at imam@cse.uiu.ac.bd
References:
Chapter 1(section 1.3), Introduction to the Theory of Computation, 3rd Edition by Michael Sipser

More Related Content

What's hot

Regular Languages
Regular LanguagesRegular Languages
Regular Languages
parmeet834
 
Chomsky Hierarchy.ppt
Chomsky Hierarchy.pptChomsky Hierarchy.ppt
Chomsky Hierarchy.ppt
AayushSingh233965
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ratnakar Mikkili
 
TOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite AutomataTOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite Automata
Mohammad Imam Hossain
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
shah zeb
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
Pumping lemma for cfl
Pumping lemma for cflPumping lemma for cfl
Pumping lemma for cfl
Muhammad Zohaib Chaudhary
 
TOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of ComputationTOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of Computation
Mohammad Imam Hossain
 
TOC 9 | Pushdown Automata
TOC 9 | Pushdown AutomataTOC 9 | Pushdown Automata
TOC 9 | Pushdown Automata
Mohammad Imam Hossain
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
Rajendran
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
VenkataRaoS1
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
Tsegazeab Asgedom
 
TOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataTOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite Automata
Mohammad Imam Hossain
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Shiraz316
 
context free language
context free languagecontext free language
context free language
khush_boo31
 
4.6 halting problem
4.6 halting problem4.6 halting problem
4.6 halting problem
Sampath Kumar S
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
FInite Automata
FInite AutomataFInite Automata
FInite Automata
Mobeen Mustafa
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptx
GhulamRabani9
 

What's hot (20)

Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Chomsky Hierarchy.ppt
Chomsky Hierarchy.pptChomsky Hierarchy.ppt
Chomsky Hierarchy.ppt
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
TOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite AutomataTOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite Automata
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Pumping lemma for cfl
Pumping lemma for cflPumping lemma for cfl
Pumping lemma for cfl
 
TOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of ComputationTOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of Computation
 
TOC 9 | Pushdown Automata
TOC 9 | Pushdown AutomataTOC 9 | Pushdown Automata
TOC 9 | Pushdown Automata
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
TOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataTOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite Automata
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
context free language
context free languagecontext free language
context free language
 
4.6 halting problem
4.6 halting problem4.6 halting problem
4.6 halting problem
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
FInite Automata
FInite AutomataFInite Automata
FInite Automata
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptx
 

Similar to TOC 5 | Regular Expressions

Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...
Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...
Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...
inventionjournals
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
Mohammad Imam Hossain
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
Mohammad Imam Hossain
 
05 8640 (update email) multiset cs closure propertie (edit lafi)2
05 8640 (update email) multiset cs closure propertie (edit lafi)205 8640 (update email) multiset cs closure propertie (edit lafi)2
05 8640 (update email) multiset cs closure propertie (edit lafi)2
IAESIJEECS
 
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix MappingDual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
inventionjournals
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
Abhimanyu Mishra
 
Automata
AutomataAutomata
Automata
Gaditek
 
Automata
AutomataAutomata
Automata
Gaditek
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
RaviAr5
 
1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt
Marvin886766
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
Mohammad Imam Hossain
 
A Fifth-Order Iterative Method for Solving Nonlinear Equations
A Fifth-Order Iterative Method for Solving Nonlinear EquationsA Fifth-Order Iterative Method for Solving Nonlinear Equations
A Fifth-Order Iterative Method for Solving Nonlinear Equations
inventionjournals
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
Matrix Transformations on Some Difference Sequence Spaces
Matrix Transformations on Some Difference Sequence SpacesMatrix Transformations on Some Difference Sequence Spaces
Matrix Transformations on Some Difference Sequence Spaces
IOSR Journals
 
Fuzzy random variables and Kolomogrov’s important results
Fuzzy random variables and Kolomogrov’s important resultsFuzzy random variables and Kolomogrov’s important results
Fuzzy random variables and Kolomogrov’s important results
inventionjournals
 
Statistical machine translation
Statistical machine translationStatistical machine translation
Statistical machine translation
Hrishikesh Nair
 

Similar to TOC 5 | Regular Expressions (20)

Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...
Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...
Matrix Transformations on Paranormed Sequence Spaces Related To De La Vallée-...
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
 
05 8640 (update email) multiset cs closure propertie (edit lafi)2
05 8640 (update email) multiset cs closure propertie (edit lafi)205 8640 (update email) multiset cs closure propertie (edit lafi)2
05 8640 (update email) multiset cs closure propertie (edit lafi)2
 
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix MappingDual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
 
draft
draftdraft
draft
 
A Fifth-Order Iterative Method for Solving Nonlinear Equations
A Fifth-Order Iterative Method for Solving Nonlinear EquationsA Fifth-Order Iterative Method for Solving Nonlinear Equations
A Fifth-Order Iterative Method for Solving Nonlinear Equations
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Matrix Transformations on Some Difference Sequence Spaces
Matrix Transformations on Some Difference Sequence SpacesMatrix Transformations on Some Difference Sequence Spaces
Matrix Transformations on Some Difference Sequence Spaces
 
Fuzzy random variables and Kolomogrov’s important results
Fuzzy random variables and Kolomogrov’s important resultsFuzzy random variables and Kolomogrov’s important results
Fuzzy random variables and Kolomogrov’s important results
 
Statistical machine translation
Statistical machine translationStatistical machine translation
Statistical machine translation
 
lec13.ppt
lec13.pptlec13.ppt
lec13.ppt
 
5. Rania.pdf
5. Rania.pdf5. Rania.pdf
5. Rania.pdf
 
5. Rania.pdf
5. Rania.pdf5. Rania.pdf
5. Rania.pdf
 

More from Mohammad Imam Hossain

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
Mohammad Imam Hossain
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
Mohammad Imam Hossain
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
Mohammad Imam Hossain
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
Mohammad Imam Hossain
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
Mohammad Imam Hossain
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
Mohammad Imam Hossain
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
Mohammad Imam Hossain
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
Mohammad Imam Hossain
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
Mohammad Imam Hossain
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
Mohammad Imam Hossain
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
Mohammad Imam Hossain
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
Mohammad Imam Hossain
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
Mohammad Imam Hossain
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
Mohammad Imam Hossain
 
DBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related QueriesDBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related Queries
Mohammad Imam Hossain
 
DBMS 9 | Extendible Hashing
DBMS 9 | Extendible HashingDBMS 9 | Extendible Hashing
DBMS 9 | Extendible Hashing
Mohammad Imam Hossain
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
Mohammad Imam Hossain
 

More from Mohammad Imam Hossain (20)

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
 
DBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related QueriesDBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related Queries
 
DBMS 9 | Extendible Hashing
DBMS 9 | Extendible HashingDBMS 9 | Extendible Hashing
DBMS 9 | Extendible Hashing
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 

Recently uploaded

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 

Recently uploaded (20)

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 

TOC 5 | Regular Expressions

  • 1. Regular Expressions CSE 2233 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 2. Regular Languages Regular Language: – A language is called a regular language if some finite automaton(DFA) recognizes it. – A language is regular if and only if some nondeterministic finite automaton(NFA) recognizes it. – If a language is described by a regular expression(RE), then it is also regular. 2 NFA DFA RE Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 3. Regular Operations ▸ 3 operations are defined on languages called Regular Operations. ▸ Here, the name Regular Operations is just a name that has been chosen for these 3 operations. ▸ Regular Operations are used to study properties of the Regular Languages. Definition: Let Σ be an alphabet and A,B ⊆ Σ* be languages. Then the regular operations are as follows:  Union: The language A⋃B ⊆ Σ* is defined as, A⋃B = { w | w ∈ A or w ∈ B }  Concatenation: The language AB ⊆ Σ* is defined as, AB = { wx | w ∈ A and x ∈ B }  Kleene star/ Star: The language A* is defined as, A* = { x1x2 … … xk | k≥0 and each xi ∈ A } 3 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 4. Regular Operations - Example Let, Alphabet Σ = { a, b, c, … … … , z } Language A = { good, bad } ⊆ Σ* Language B = { boy, girl } ⊆ Σ* Then, A⋃B = { good, bad, boy, girl } AB = { goodboy, goodgirl, badboy, badgirl } A* = { 𝜀, good, bad, goodgood, goodbad, badgood, badbad, goodgoodgood, goodgoodbad, … … } 4 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 5. Regular Languages – Closure Property ▸ The regular languages are closed with respect to the regular operations: if A, B ⊆ Σ* are regular languages, then the languages A⋃B, AB, and A* are also regular. ▸ There are many other operations on languages aside from the regular operations under which the regular languages are also closed.  Subtraction: The language AB ⊆ Σ* is defined as, AB = { w | w ∈ A and w ∉ B } = A⋂ഥB  Complement: The language ഥA ⊆ Σ* is defined as, ഥA = { w | w ∈ Σ* and w ∉ A } = Σ*A  Intersection: The language A⋂B ⊆ ∑* is defined as, A⋂B = { w | w ∈ A and w ∈ B } = ҧ𝐴 ∪ ത𝐵  Reverse: The language AR ⊆ Σ* is defined as, AR = { wk wk-1 … … w2 w1 | w=w1w2 … … wk ∈ A } 5 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 6. Regular Expressions Arithmetic Expressions: ▸ We use the operations + and x to build up expressions such as (5+3)x4 ▸ The value of arithmetic expression is the number 32. Regular Expression: ▸ We use regular operations to build up expressions describing languages called Regular Expressions. ▸ The value of regular expression is a language. ▸ For example, (0⋃1)0* Note: REs have an important role in computer science applications. It provides powerful methods to describe different string patterns in UNIX commands, modern programming languages, text editors etc. 6 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 7. Regular Expressions – Definition Regular Expression: R is a regular expression if R is ▸ a for some a in the alphabet Σ, ▸ 𝜀, ▸ 𝜙, ▸ (R1 ⋃ R2), where R1 and R2 are regular expressions, ▸ (R1 o R2), where R1 and R2 are regular expressions, or ▸ (𝑅1 ∗ ), where R1 is a regular expression. 7 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 8. Regular Expressions – Precedence Order 8 Precedence of Regular Operations: 1. Parentheses 2. Star 3. Concatenation 4. Union So according to the precedence sequence: (ab U a)* = ( ( (a) (b) ) U ( a ) ) * Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 9. RE – Practices 9 Language, L(R) Regular Expression { w | w contains a single 1 } 0* 1 0* { w | w consists of exactly three 1’s } 0* 1 0* 1 0* 1 0* { w | w has at least a single 1 } (0 | 1)* 1 (0 | 1)* { w | w contains at least three 1’s } (0 | 1)* 1 (0 | 1)* 1 (0 | 1)* 1 (0 | 1)* { w | w has at most one 1 } 0* | 0* 1 0* { w | w contains an even number of 1’s } (0* 1 0* 1 0*)* 0* { w | the number of 1’s withing w can be evenly divided by 3 } (0* 1 0* 1 0* 1 0* )* 0* { w | w is a string of even length } (ΣΣ)*, here Σ = (0 | 1) { w | the length of w is a multiple of 3 } (ΣΣΣ)*, here Σ = (0 | 1) Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 10. RE – Practices 10 Language, L(R) Regular Expression { w | w starts with 101 } 101 (0 | 1)* { w | w contains the string 001 as a substring } (0 | 1)* 001 (0 | 1)* { w | w ends with 3 consecutive 1’s } (0 | 1)* 111 { w | w doesn’t end with 11 } 𝜀 | 0 | 1 | (0 | 1)* (00 | 01 | 10) { w | w ends with an even nonzero number of 0’s } ( (0 | 1)* 1 | 𝜀 ) 00 (00)* { w | w starts and ends with the same symbol } 0 | 1 | 0Σ*0 | 1Σ*1, here Σ = (0 | 1) { w | w has at least 3 characters and the 3rd character is 0 } (0 | 1) (0 | 1) 0 (0 | 1)* { w | every zero in w is followed by at least one 1 } 1* (01+)* { w | w consists of alternating zeros and ones } (1 | 𝜀) (01)* (0 | 𝜀) Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 11. RE – Practices 11 Language, L(R) Regular Expression { 01, 10 } 01 | 10 01* | 1* (0 | 𝜀) 1* { 𝜀, 0, 1, 01 } (0 | 𝜀) (1 | 𝜀) 𝜙 R𝜙 { 𝜀 } 𝜙* { w | w starts with 0 and has odd length or, starts with 1 and has even length } 0 ( (0 | 1) (0 | 1) )* | 1 (0 | 1) ( (0 | 1) (0 | 1) )* Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 12. RE  NFA ▸ R = a for some a ∈ Σ. Then L(R) = { a }, and the following NFA recognizes L(R) ▸ R = 𝜀 . Then L(R) = { 𝜀 } and the following NFA recognizes L(R) ▸ R = 𝜙 . Then L(R) = 𝜙, and the following NFA recognizes L(R) ▸ R = R1 U R2 , so L(R) = L(R1) U L(R2) = NFA1 recognizes L(R1) U NFA2 recognizes L(R2) ▸ R = R1 o R2 = R1R2 = = L(R1) o L(R2) = NFA1 recognizes L(R1) o NFA2 recognizes L(R2) ▸ R = R1 * = L(R1)* = ( NFA1 recognizes L(R1) )* 12 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 13. RE  NFA : Example 1 Convert the following RE to equivalent NFA: (ab U a)* 13 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 14. RE  NFA : Practices 14 ▸ ( a U b ) * a b a ▸ ( 0 U 1 ) * 0 0 0 ( 0 U 1 )* = Σ* 0 0 0 Σ* where Σ = 0, 1 = 0 U 1 ▸ ( ( ( 0 0 )* ( 1 1 ) ) U 0 1 ) * ▸ ( 0 1 U 0 0 1 U 0 1 0 ) * ▸ a ( a b b ) * U b ▸ a+ U ( a b ) + ▸ ( a U b+ ) a+ b+ [ Hint: replace a+ with (a a*) ] ▸ 1* ( 0 1+)* ▸ ( Σ Σ Σ ) * ▸ 0 Σ* 0 U 1 Σ* 1 U 0 U 1 ▸ 𝜙* ▸ ( 0 U 𝜀 ) 1* Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 15. DFA  GNFA  RE 15 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Steps to follow:
  • 16. GNFA ▸ A GNFA is a nondeterministic finite automaton(NFA) in which each transition is labeled with a regular expression over the alphabet set instead of only members of the alphabet or 𝜀. ▸ A single initial state with all possible outgoing transitions and no incoming transitions. ▸ A single final state without outgoing transitions but all possible incoming transitions. The accept state is not the same as the start state. ▸ A single transition between every two states, including self loops. 16 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 17. GNFA – Formal Definition A generalized nondeterministic finite automaton is a 5 tuple, (Q, Σ, 𝛿, qstart, qaccept ), where ▸ Q is the finite set of states ▸ Σ is the input alphabet ▸ 𝛿: ( Q - {qaccept} ) x ( Q - {qstart} )  ℛ is the transition function [if you travel from state a 𝜖 ( Q - {qaccept} ) to state b 𝜖 ( Q - {qstart} ) then this relation will generate ℛ regular expression ] ▸ qstart is the start state and ▸ qaccept is the accept state 17 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 18. GNFA – State Minimization Rule 18 Removing qrip state, Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 19. DFA  GNFA : Steps to Follow 19 ▸ Add a new start state with an 𝜀 arrow to the old start state ▸ Add a new accept state with 𝜀 arrows from the old accept states to this new accept state ▸ If any arrows have multiple labels, replace each with a single arrow whose label is the union of the previous labels ▸ Add arrows labeled 𝜙 between states that had no arrows. [better no to show this in the diagram, for simplicity] Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 20. CONVERT(G): 1. Let k be the number of states of G. 2. If k=2, then G must consist of a start state, an accept state, and a single arrow connecting them and labeled with a regular expression R — Return the expression R. 3. If k>2, we select any state qrip ∈ Q different from qstart and qaccept and let G’ be the GNFA (Q’, Σ, 𝛿’, qstart, qaccept), where Q’ = Q - {qrip} and for any qi ∈ Q’–{qaccept} and any qj ∈ Q’–{qstart}, let 𝛿’(qi, qj) = (R1) (R2)*(R3) U (R4) for R1 = 𝛿(qi, qrip), R2 = 𝛿(qrip, qrip), R3 = 𝛿(qrip, qj), and R4 = 𝛿(qi, qj) 4. Compute CONVERT(G’) and return this value. GNFA  RE : Algorithm 20 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 21. GNFA  RE : Removing State 2 21 Here, 2 is associated with states 1 and a. All possible combinations are (1,1), (1,a), (a,a), (a,1). But there will be no outgoing from a, so no need to consider (a,a) and (a,1) states. For (1,1), R = a U (b (aUb)* 𝜙)) = a Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 22. GNFA  RE : Removing State 2 22 Here, 2 is associated with states 1 and a. All possible combinations are (1,1), (1,a), (a,a), (a,1). But there will be no outgoing from a, so no need to consider (a,a) and (a,1) states. For (1,a), R = 𝜙 U (b (aUb)* 𝜀) = b(aUb)* Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 23. GNFA  RE : Removing State 1 23 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 24. DFA  GNFA  RE : Example 2 24 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 25. DFA  GNFA  RE : Practices 25 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Practice 1 Practice 2
  • 26. 26 THANKS! Any questions? You can find me at imam@cse.uiu.ac.bd References: Chapter 1(section 1.3), Introduction to the Theory of Computation, 3rd Edition by Michael Sipser