TOA Lesson 04

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

Recap Lecture 3

 Regular expression of EVEN-EVEN


language, Difference between a* + b* and
(a+b)*, Equivalent regular expressions;
sum, product and closure of regular
expressions; regular languages, finite
languages are regular, introduction to
finite automaton, definition of FA,
transition table, transition diagram.

1
Recap Lecture 4

 Different notations of transition diagrams,


languages of strings of even length, Odd
length, starting with b, ending in a,
beginning with b, not beginning with
b, beginning and ending in same
letters;

2
Regular Expression

 As discussed earlier that a* generates


Λ, a, aa, aaa, …
and a+ generates a, aa, aaa, aaaa, …, so
the language L1 = {Λ, a, aa, aaa, …} and
L2 = {a, aa, aaa, aaaa, …} can simply
be expressed by a* and a+, respectively.
a* and a+ are called the regular expressions
(RE) for L1 and L2 respectively.
Note: a+, aa* and a*a generate L2.
3
Recursive definition of Regular
Expression(RE)

Step 1: Every letter of Σ including Λ is a regular


expression.
Step 2: If r1 and r2 are regular expressions then
1.(r1)

2.r1 r2

3.r1 + r2 and

4. r1*
are also regular expressions.
Step 3: Nothing else is a regular expression.

4
Defining Languages (continued)…

 Method 3 (Regular Expressions)


 Consider the language L={Λ, x, xx, xxx,…}
of strings, defined over Σ = {x}.
We can write this language as the Kleene
star closure of alphabet Σ or L=Σ*={x}*
this language can also be expressed by the
regular expression x*.
 Similarly the language L={x, xx, xxx,…},
defined over Σ = {x}, can be expressed by
the regular expression x+.

5
 Now consider another language L,
consisting of all possible strings, defined
over Σ = {a, b}. This language can
also be expressed by the regular
expression
(a + b)*.
 Now consider another language L, of
strings having exactly double a, defined
over Σ = {a, b}, then it’s regular
expression may be
b*aab*
6
 Now consider another language L, of
even length, defined over Σ = {a, b},
then it’s regular expression may be
((a+b)(a+b))*
 Now consider another language L, of
odd length, defined over Σ = {a, b},
then it’s regular expression may be
(a+b)((a+b)(a+b))* or
((a+b)(a+b))*(a+b)

7
Remark

 It may be noted that a language may be


expressed by more than one regular
expressions, while given a regular
expression there exist a unique language
generated by that regular expression.

8
 Example:
 Consider the language, defined over
Σ={a , b} of words having at least one a,
may be expressed by a regular
expression
(a+b)*a(a+b)*.
 Consider the language, defined over
Σ = {a, b} of words having at least one a
and one b, may be expressed by a
regular expression
(a+b)*a(a+b)*b(a+b)*+ (a+b)*b(a+b)*a(a+b)*. 9
 Consider the language, defined over
Σ={a, b}, of words starting with double
a and ending in double b then its
regular expression may be aa(a+b)*bb
 Consider the language, defined over
Σ={a, b} of words starting with a and
ending in b OR starting with b and
ending in a, then its regular expression
may be a(a+b)*b+b(a+b)*a

10
TASK

 Consider the language, defined over


Σ={a, b} of words beginning with a,
then its regular expression may be a(a+b)*

 Consider the language, defined over


Σ={a, b} of words beginning and
ending in same letter, then its regular
expression may be (a+b)
+a(a+b)*a+b(a+b)*b

11
TASK

 Consider the language, defined over


Σ={a, b} of words ending in b, then
its regular expression may be (a+b) *b.
 Consider the language, defined over
Σ={a, b} of words not ending in a,
then its regular expression may be (a+b) *b
+ Λ. It is to be noted that this language
may also be expressed by ((a+b) *b)*.

12
SummingUP Lecture 4

RE, Recursive definition of RE, defining


languages by RE, { x}*, { x}+, {a+b}*,
Language of strings having exactly one aa,
Language of strings of even length,
Language of strings of odd length, RE defines
unique language (as Remark), Language of
strings having at least one a, Language of
strings havgin at least one a and one b,
Language of strings starting with aa and
ending in bb, Language of strings starting
with and ending in different letters.

13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy