Chapter 4
Chapter 4
Chapter 4
4
The notation x* can be used to define languages
by writing, say L = language (x*)
5
Given the alphabet = {a, b}, suppose we wish to define the
language L that contains all words of the form one a followed by
some number of b’s (maybe no b’s at all); that is
L = {a, ab, abb, abbb, abbbb, …}
6
We can apply the Kleene star to the whole
string ab if we want:
(ab)* = Λ or ab or abab or ababab…
Observe that
(ab)* ≠ a*b*
because the language defined by the
expression on the left contains the word
abab, whereas the language defined by
7
the expression on the right does not.
If we want to define the language L1 = {x; xx; xxx; …}
using the language-defining symbol, we can write
L1 = language(xx*)
which means that each word of L1 must start with an x
followed by some (or no) x’s.
8
Plus Sign
11
Example
12
Regular Expressions
Given = {a,b}
a* = {Λ, a,aa,aaa,aaa,aaaa,aaaaa, …}
ab* = {a, ab,abb,abbb,abbbb, …}
a+b = {a,b}
(ab)* = {Λ, ab, abab, ababab, …}
(a+b)* = {Λ, any string of as and bs}
Formal Definition of Regular
Expressions
The set of regular expression is defined by
following rules
1. Every letter of and Λ is a regular
expression
2. If r1 and r2 are regular expressions, then so
are
(r1)
r1r2
r1+r2
r1*
17
[Section 1.3]
Regular expressions
19
Regular Expression
Identities
Regular Expression Identities
1. u = u = u
2. * =
3. u+v=v+u
4. u+u=u
5. u* = (u*)*
6. u (v + w) = uv + uw
7. (u + v) w = uw + vw
20
Languages Associated
with Regular
Expressions
Definition
language(r1r2) = L1L2
22
Definition contd.
Rule 2 (cont.):
Proof
The language of all words that have at least two a’s can
be defined by the expression:
(a + b)*a(a + b)*a(a + b)*