===============================================================
Lect 8 - October 21, 2008 - ECS 20 - Fall 2008 - Phil Rogaway
===============================================================
Today: o Regular languages, continued
o Relations
- SCRIBE (none today, use your own notes for the class notes)
--------------------------------------------------
1. Reviews strings, languages, and their operators
--------------------------------------------------
Strings emptystring
concatenation
length
reversal
substring extraction
x^k
Language concatenation operator
L^k
Kleene closure
union, intersect, complement
-----------------------------------------------------------
2. Regular languages - the languages of regular expressions
-----------------------------------------------------------
Formally, given an alphabet Sigma, the following are the regular
expressions over Sigma:
-a, for all a\in\Sigma
-emptystring symbol
-emptyset symbol
-(x o y), (x u y), (x*) for any regular expressions x,y
Omit parenthesis with the understanding that o binds most strongly,
then *, then u, and things group left-to-right,
L(\alpha) - the language of a regular expression - defined
recursively in the natural way.
Exercise 1: write a regular expression for all strings over {a,b}
whose length is divisible by 3.
(aub)(aub)(aub))*
Exercise 2: write a regular expression for all strings over {a,b}
whose length is NOT divisible by 3.
(aub)(aub)(aub))*(aub) u
(aub)(aub)(aub))*(aub)(aub)
Exercise 3: write a regular expression for all strings over {0,1}
that contain _some_ '111'.
(0u1)* 111 (0u1)*
Exercise 4: write a regular expression for all strings over {0,1}
that contain an even # of 0's and an even # of 1's.
Hmm...... sounds HARD!
Can it be done?!
------------------------------------------
3. DFAs
------------------------------------------
Describe pictorially (no actual definition).
What they capture: a computer with a finite amount of memory.
Make a DFA for each of the languages above.
Theorem (ecs 120): L is the language of a regular expression
iff
L is the language of a DFA
So now we _know_ that example 4 does have a regular expression,
just our own stupidity not to be able to write it.
Nice new ways to describe languages: give a DFA.
------------------------------------------
4. Relations
------------------------------------------
(Change of topics. But do define some relations on
strings, regular languages, and DFAs to tie the
two topics together.)
DEF: A and B sets. Then a *relation* R is subset of A x B.
R \subseteq A x B
Variant notation: x R y for (x,y) \in R
May use a symbol like ~ or < for a relations
x ~ y if (x,y) \in ~
Relations in arithmetic, where A and B are both natural numbers:
= < <= > >=
| divides
what about succ, +, * NO: function symbols, not relations
In set theory:
in = subseteq
what about emptyset NO: constant symbol
Relations are useful for things other than numbers and sets and the like:
S = all UCD students for F08
C = all UCD classes for F08
P = all UCD professors for F08
E: enrolled relation \subseteq S x C
s E c (ie, (s,c)\in E) - x is taking class y
T: teaches relation \subseteq C x P
c T p (ie, (c,p)\in T) - professor p is teaching class c this term
You can *compose* relations
what _should_
E o T
mean,do you think
E o T \subseteq S x P S x C C x P -> S x P
s EoT p if there exists c in C such that s E c and c T p --
student s is taking some course that p is teaching --
p is s's teacher this term
What I've just given is the general definition
R \subseteq X x Y
S \subseteq Y x Z then R o S \subseteq X x Z is {(x,z): \exists y in Y xRy and yRz}
DRAW A GRAPH -- and give the directed-graph interpretation of
Students Classes Instructors
-------- ------- ------------
John ECS20 Prof. Rogaway
Nina Math118 Prof. Hamann
Till ECS20 Prof. Morrison
Elizabeth Lin 10 Prof. Samuelson
Ali
What _should_ E^{-1} should be?
formalize
if R\subseteq X x Y is a relation that R^{-1} is the relation on Y x X
where (y,x) R^{-1} iff x R y.
More examples:
Often X = Y is the *same* set
Relations on natural numbers, real numbers, strings, etc.
X = set of strings
x <= y "is a substring of y"
alpha and bet are regular expressions.
alpha ~ beta if L(alpha) = L(beta)
T/F: (0u1)^*(0u1)^* ~ (00 u 01 u 10 u 11)^* TRUE
emptystring ~ emptystring* TRUE
0(0u1)0 ~ 1(0u1)1 FALSE
M and M' are DFAs.
M ~ M' if L(M) = L(M')
M subseteq M' if L(M) subseteq L(M')
------------------------------------------
5. Properties of Relations
------------------------------------------
Reflexive: x R x for all x
Symmetric: x R y -> y R x for all x,y
Transitive: x R y and y R x -> x R z for all x, y, z
if R has all three properties, R is said to be an equivalence relation
...