Lecture No. 03
Dated: 25-10-2024
Regular Expression
Imagine we have
\[\Sigma = \{a\}\]
\[L = \{a, aa, aaa, \ldots\}\]
We know that it is represented by \(\Sigma^+\).
Then \(a^+\) would be called the regular expression
.
Recursive Definition of Regular Expression
- Every
letter
of \(\Sigma\), including \(\Lambda\) is aregular expression
. -
If \(r_1\) and \(r_2\) are
regular expressions
then following are alsoregular expressions
.-
\[r_1\]
-
\[r_1 r_2\]
-
\[r_1 + r_2\]
-
\[r_1^*\]
-
-
Nothing else is
regular expression
.
A language
maybe be generated by more than one regular expressions
Examples
Imagine we have \(\Sigma = \{a, b\}\) then
Example
A language
\(L\) consisting of all combinations of symbols
is defined as \((a + b)^*\).
The \((a + b)\) represents a single letter
which can be either \(a\) or \(b\).
Example
A language
containing at least 1 \(a\) symbol
in each string
1 is defined as \(b^*ab^*\).
Example
A language
containing strings
1 of even length is defined as \(((a + b) (a + b))^*\)