Title: Computer Science 500 Theory of Computation Fall, 1998 August 27
1- Lecture 8
September 14 - Goals
- regular expressions
- equivalence of NFA and regular expressions
- application of regular expressions
2regular expressions If L can be accepted by an
NFA, then L can be accepted by a DFA. Class of
languages accepted by NFA and DFA is called
regular languages. Regular expression is another
way to describe regular languages. We will show
A language is regular if and only if we can
create a regular expression for it.
3- Regular
expressions - Some applications use regular expressions, some
use NFA and some use DFA so knowing all of them
are useful. - In some cases, even though the right tool to use
may be an NFA, it may be easier to first create a
regular expression, then convert it to NFA. - Programming Languages that support extensive
string operations (via powerful regular
expression packages) - Awk
- Snobol
- Perl etc.
4Operations on Strings
- Concatenation
- for strings w w1 w2 wn , v v1 v2 vm
where wi, vj are in ?, - w v w1 w2 wnv1 v2 vm
- Concatenation of languages L1 and L2
- L1 . L2 u v u is in L1 and v is in L2
- Set operations union, intersection etc. on
languages
5Examples
If w 01101, v 10110, then wv concatenation
of w with v 0110110110 w2 ww
0110101101 Note for all string x, y and
integers i, xy x y, xi ix
6Operations on Languages
- Concatenation S1S2 s1s2 s1 ? S1, s2 ?
S2 - Union S1 U S2 s s ? S1 ? s ? S2
- Kleene Star S ? U s1s2 ...sn
?i, si ? S
7Examples
Note we sometimes abuse notation and refer to a
set containing one string w as w instead of w.
If w 10, v 011, then w U v w U v
10,011 w e, 10, 1010, 101010, (w U
v) e, 10, 011, 10011, 01110, 011011, 1010,
101010, (w v) e, 10011, 1001110011,
100111001110011,
8Regular Expressions over ?
Regular expressions over S is defined recursively
as follows Base cases a where a in ?, R ?,
and R f are regular expressions that represent
the languages L(a) a, L(?) ? and L(f)
f Recursively If R1and R2 are regular
expressions, then so are R1 U R2 (or R1 R2),
R1R2 and R1 are regular expressions that
represent the languages L(R1 R2) L(R1)
U L(R2) L(R1R2) L(R1) . L(R2) and
L(R1) L(R1)
9Some simple examples Example 1 The set of
strings over 0,1 that have 01 or 10 as a
substring. (01) (10 01)
(01) Example 2 The set of strings over 0, 1,
2, , 9, . that represent a real number in
standard decimal format. (129)(019).(0
19)0.(019) Example 3 The set of
strings over 0,1 of even length
10 Some examples Example 4 Write a regular
expression for the set of strings over 0,1 that
do not have 00 as a substring.
11- Theorem A language is regular if and only if it
is accepted by a regular expression. - Proof convert from regular expression to NFA and
vice-versa. - Let L be accepted by a regular expression. We
prove that it is regular, I.e., there is a NFA
for L. - Cases to consider
- empty-set F (2) single symbol a in S (3) e
- (a) R1 R2
- (b) R1 . R2
- (c) R1
- In each case, we can inductively construct NFAs
for R1 and R2, and from it construct a NFA for R.
12(No Transcript)
13Proof of the converse (page 98 to 100)