Você está na página 1de 4

COMP 181

Models of Languages and Computation


Spring 2001
Mid Semester Exam
Monday, Feb. 26, 2001
Closed Book - Closed Notes
Don't forget to write your name or ID and pledge on the exam sheet.
This exam has four pages.

1. (5 points)
a) Suppose is the relation f(1 3) (2 3)g and is the relation f(3 4) (3 5)g.
R ; ; ; S ; ; ;

What is the relation Æ obtained by omposing and ? List all ordered


R S R S

pairs in the relation.

b) Suppose that and are arbitrary relations having exa tly four
R S

ordered pairs. (In part (a), both relations have two ordered pairs.) What is
the largest possible number of ordered pairs in the relation Æ ? R S

2. (5 points) If is a relation, let


R
TR be with all ordered pairs
R

reversed. Thus if is f(0 1) (0 4)g then


R ; ; ; R
T is f(1 0) (4 0)g. True or false:
; ; ;

a) If a relation is symmetri , then


R R
T is always symmetri .
b) If a relation is re exive, then
R R
T is always re exive.
) If a relation is transitive, then
R R
T is always transitive.
3. Consider the following regular expressions:
a) (0 10 10 ) (1 0)
b) 0 [ (0 10 10 )

1
) ((0 [ 1)(0 [ 1))
d) 0 10 10
e) ((0 [ 1)(0 [ 1)) (0 [ 1)
Whi h of these represent the following sets of strings?
A) The set of binary strings ontaining exa tly two ones.
B) The set of binary strings of even length.
C) The set of binary strings of odd length.
D) The set of binary strings ontaining an even number of ones.
E) The set of binary strings ontaining an odd number of ones.
4. (10 points) Consider the following sets of strings:
a) f 2 f0 1g : has an even number of zeroesg
x ; x

b) f 2 f0 1g : has an odd number of zeroesg


x ; x

) f 2 f0 1g : has even lengthg


x ; x

d) f 2 f0 1g : has odd lengthg


x ; x

For ea h of the following nite automata M , state whi h set of strings


above is ( ):
L M

A)

B)

2
C)

D)

5. (10 points) Consider the following nondeterministi nite automaton


M :

Whi h of the following automata are both deterministi and equivalent


to ?M

a)

b)

d)

6. (10 points) Consider the following proof:


Theorem. Suppose is a nondeterministi nite automaton. Let 0
M M

be identi al to ex ept that the a epting and non-a epting states of


M M

have been swit hed; that is, a state is an a epting state of 0 exa tly
q M

when is not an a epting state of . Let  be the input alphabet of


q M M

and 0 . Then ( 0 ) =  ( ).
M L M L M

Proof. Consider a word 2  . Suppose a epts . Then there is


x M x

a omputation starting from the start state of , leading to an a epting


M

3
state of . The same omputation will lead to the state of 0 , but is
r M r M r

not an a epting state of 0 . Therefore 0 does not a ept .


M M x

Similarly, if does not a ept , then there is a omputation leading


M x

from the start state of to a non-a epting state of . Sin e is a non-


M t M t

a epting state of , is an a epting state of 0 . Therefore 0 a epts


M t M M

x .
Therefore, 0 a epts exa tly when does not a ept , so ( 0 ) =
M x M x L M

  L M( ).
Is this proof orre t? If so, say why. If not, say why not.

7.) Suppose 1 and 2 are deterministi nite automata. Is there


M M

always a deterministi nite automaton su h that ( ) = ( 1 )


M L M L M

( 2 ), that is, a epts a word exa tly when 1 a epts the word and
L M M M

M 2 does not a ept the word. Justify your answer brie y.

Você também pode gostar