Professional Documents
Culture Documents
LECTURE 4a
CHAPTER 1
SHORT QUESTIONS
{} and {, {}}
so 2
(L1 L2 ) L = (L1 L ) (L 2 L )
yes Languages are sets hence all laws of algebra of sets
hold for them
Q10 L = {w1 w2 . . . wn : wi L , i = 1, 2, ..n, n 1}
no
n0
CHAPTER 1
Some Homework Problems
Problem 1
Problem 1
Consider the following languages over = {a , b }
L1 = {w ? : u (w = uuR u)}
L2 = {w ? :
ww = www }
Problem 1
We evaluated that = {a , b }{a , b } = {aa , bb , ab , ba }
We defined L1 = {w ? : u (w = uuR u)}
By evaluation we have that
L1 = {aaaaaa , abbaab , baabba , bbbbbb }
Part 2: Give examples of 2 words over such that w < L1
Solution a < L1 , bba < L1
There are countably infinitely many words that are not in L1
Problem 1
Part 3
ww = www }
Show that L2 ,
Solution e L2 , as ee = eee
In fact, e is the only word with this property, hence
L2 = {e }
Part 4 Show that the set (? L2 ) is infinite
Solution ? is countably infinite, L2 is finite, so (basic
theorem) (? L2 ) is countably infinite
Any w ? , such that w , e is in (? L2 )
Problem 2
Problem 2
Given expressions (written in a short hand notation)
1 = ? a ? b ? a b (a b )?
2 = (a b )? b (a b )?
Part 1 Re-write 1 as a simpler expression representing the
same language
List properties you used in your solution
Describe the language L = L(1 )
Problem 2
Solution
We first evaluate
L(1 ) = L(? a ? b ? a b (a b )? )
= e {a }? {b }? {a } {b } ({a } {b })? = ?
This is true because of the properties:
1 = ? a ? b ? a b (a b )? = (a b )?
Problem 3
Part 2 Given
2 = (a b )? b (a b )?
Problem 3
Problem 3
Let = {a , b } and a language L ? be defined as follows:
L = {w ? : w contains no more then two as}
Write a regular expression , such that L() = L . Use
shorthand notation. Explain shortly your answer.
Solution
= b ? b ? ab ? b ? ab ? ab ?
Explanation
b ? contains 0 of as (case n=0)
b ? ab ? contains 1 occurrence of a (case n=1)
b ? ab ? ab ? contains 2 occurrence of a (case n=2)
Problem 4
Problem 4
Let = {a , b }
The language L ? is defined as follows:
L = {w ? :
= a ? (a ? ba ? ba ? ba ? ba ? )? = a ? (ba ? ba ? ba ? ba ? )?
Observe that the regular expression a ? ba ? ba ? ba ? ba ?
describes a string w ? with exactly four b s
Problem 4
The regular expression
(a ? ba ? ba ? ba ? ba ? )?
represents multiples of w ? with exactly four b s and
hence words in which a number of b s is divisible by 4
Observe that 0 is divisible by 4, so we need to add the case
of 0 number of b s, i.e. we need to include words
e , a , aa , aaa , , ...
We do so by concatenating (a ? ba ? ba ? ba ? ba ? )? with a
and get
L = a ? (ba ? ba ? ba ? ba ? )?
Problem 5
Problem 5
1. Let
A = {({n, n + 1}, n) 2N N : 1 n 3}
Problem 5
2. Let now A = {({n}, n) 2N N : 1 n n + 1}
Prove that A is infinitely countable
Solution
Observe that the set A can be re-written as follows
A = {({n}, n) 2N N : 1 n n + 1}
= {({n}, n) 2N N : 1 n}
because n n + 1 for all n N
The set B = {{n} : n N } has the same cardinality as N by
the function f (n) = {n}
A = B N is hence a Cartesian product of two infinitely
countable sets, and as we have proved, an infinitely
countable set
Problem 6
Problem 6
Let L be a language defines as follows
L = {w {a , b } : P (a , b )}
for the property P(a,b) defined as follows
P(a,b): between any two as in w there is an even number of
consecutive bs
1. Describe a regular expression r such that L(r ) = L
Remark that 0 is an even number, hence a L and
r = b b a b b (a (bb ) a ) b = b a b b (a (bb ) a ) b
Problem 7
Problem 7
Let be any alphabet, L1 , L2 two languages over such
that e L1 and e L2
Show that
(L1 ? L2 )? = ?
Solution
By definition, L1 ? , L2 ? and ? ?
Hence
(L1 ? L2 ) ?
Problem 7
Now we use the following property:
Property
For any languages L1 .L2 ,
if L1 L2 , then L1 L2
and obtain that (L1 ? L2 )? ? = ? , i.e. we proved that
(L1 ? L2 )? ?
We have to show now that also
? (L1 ? L2 )?
Let w ? , we have that also w (L1 ? L2 )? because
w = ewe and e L1 and e L2 . We have hence proved
that
(L1 ? L2 )? = ?
Problem 8
Problem 8
Let L be a function that associates with any regular
expression the regular language L = L()
1. Evaluate L = L() for = (a b )? a
Solution
L = L((a b )? a ) = L((a b )? )L(a ) = (L(a b ))? {a } =
(L(a ) L(b ))? {a } = ({a } {b })? {a } = {a , b }? {a }
2 Describe a property that defines the language
L = L((a b )? a )
Solution
L = {a , b }? {a } = ? {a } = {w {a , b }? : w ends with a }