0% found this document useful (0 votes)
8 views15 pages

Lecture 7 Regular Expression Lec

The lecture covers the definition and properties of regular expressions (RE) in automata theory, including rules for constructing REs and examples of languages they define. It discusses operations such as union and concatenation, the concept of finite languages being regular, and introduces Kleene's star. Additionally, various examples of languages defined by REs are provided, illustrating their applications.

Uploaded by

ayeshanadeem2408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views15 pages

Lecture 7 Regular Expression Lec

The lecture covers the definition and properties of regular expressions (RE) in automata theory, including rules for constructing REs and examples of languages they define. It discusses operations such as union and concatenation, the concept of finite languages being regular, and introduces Kleene's star. Additionally, various examples of languages defined by REs are provided, illustrating their applications.

Uploaded by

ayeshanadeem2408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Lecture # 7

(Automata Theory)
Instructor
Waheed Ahmad Khan
CUI Wah Campus
 Topic Covered
1. Recursive Language Definition Revision
2. Regular Expression (RE)
Definition Of Regular
Expression
(RE)
Definition: Given an alphabet Σ, the set of regular expressions is
Definition: Given an alphabet , the set of regular expressions is
defined by the following rules.
1. For every letter in Σ, the letter written in bold is a
regular expression.
Null is a regular Expression.
2. If r1 and r2 are regular expressions, then so are:
1. (r1)
2. r1 r2
3. r1+r2
4. r1 *
3. Nothing else is a regular expression.

Remark: Notice that r1 + = r1r1 *


Regular Expression
 The only words that do not contain
both an a and a b in them
somewhere are the words formed
from all a’s or all b’s, and
 L: a*+b*
Regular Expression with ^
Null
 Example:The language of all words formed
from some b’s (possibly 0) and all words where
an a is followed by some b’s (possibly 0):
 {L, a, b, ab, bb, abb, bbb, abbb, bbbb, …}

b* + ab * = (Λ+ a)b*
In general: concatenation is distributive
over the + operation.r
 r1(r2+r3) = r1r2+r1r3

 (r1+r2) r3= r1r3 +r2r3


Regular Expression With
Union
 Example of the distributive rule:(a+c)b* = ab*+cb*
 2 operations: language(s) ->language

If S and T are two languages from the same alphabet S,


1. S+T: the union of languages S and T defined as S∪T
2. ST: the product set is the set of words x written vw
with v a word in S and w a word in T.
Example: S = {a, bb} T = {a, ab}
ST = {aa, aab, bba, bbab}
Theorem
Language associated with a regular expression is defined by the
following rules.
1. The language associated with a regular expression that is just a
single letter is that one-letter word alone. The language ssociated
with Λ is {Λ}.
2. If L1 is the language associated with the regular expression r1 let L2 is the

language associated with the regular expression r2:


(i) The product L1L2 is the language associated with the regular
expression r1r2, that is: language(r1r2) = L1L2
(ii) The union L 1+L2 is the language associated with the regular
expression r1+r2, that is: language(r+r2) = L1+L2
(iii) The Kleene closure of L1, written L1*, is the language associated
with the regular expression r1*, that is language (r1*) = L1*
RE
 Remark:For allregular expressions,
there is some language associated
with it.
Finite Languages are
Regular
 Let L be a finite language. There is a
regular expression that defines it.
Algorithm(and proof)
 Write each Word in L in bold, and
write a + between regular
expressions
Example:L = {baa, abbba, bababa}
baa + abbba + bababa
Finite Languages are
Regular
 The regular expression that is defined by
this algorithm is not necessarily unique.
Example: L = {aa, ab, ba, bb}
aa + ab + ba + bb or (a+b)(a+b)
 Remark:This algorithm does not work for
infinite languages. Regular expressions
must be finite, even if the language
defined is infinite.
Kleen’s Star Of RE
 Kleene star applied to a subexpression
with a star
(a+b*)* (aa+ab*)*
(a+b*)* = (a+b)* (aa+ab*)* ≠(aa+ab)*
 (a*b*)*

The letter a and the letter b are in


language(a*b*).
(a*b*)* = (a+b)*
Regular Expression
 Examples: L1=Words with a double letter:
r1= (a+b)*(aa+bb)(a+b)*
 L2= Words without a double letter: (ab)*

But not words that begin with b or end with


a:
r2= (Λ+b)(ab)*(Λ+a)
What if we take union of above two Languages
L1+L2=r1+r2
(a+b)*(aa+bb)(a+b)* + (Λ+b)(ab)*(Λ+a)
EVEN-EVEN.
Language EVEN-EVEN defined by the
expression:
[aa + bb + (ab + ba)(aa+bb)*(ab + ba)]*
Every word in EVEN-EVEN has an even
number
of a’s and b’s.
Every word that contains an even number of
a’s
and b’s is a member of EVEN-EVEN.
More Examples of RE
 Even number of a’s
 Odd Number of a’s
 All words of length 4
 All words in which a never double
 All words do not contain ab
 All words having substring aab or baa
 All words of 3 or more
 All words of length 5 or less
Thank You…

You might also like