Sie sind auf Seite 1von 3

Assignment 1

for Formal Languages and Automata Theory


TDDD14, TDDD85
Deadline: Monday 20 April 2015 (Week 17) at 13:00

For all the problems below it is not sufficient just to give a solution. Justify your
answers. At the final exam unexplained answers will be granted 0 points. (For
example, assume that you are constructing an automaton for a given language.
Then you should also explain that the automaton indeed accepts the language).
It is allowed to discuss the exercises with others, but you are supposed to
solve each exercise individually. It is absolutely not allowed to copy solutions from
others.
Your solutions should be handed in to your tutorial assistant Jonas Wallgren
or Johannes Schmidt at a lecture or a tutorial or by using the Post till IDA
postbox in front of Java Cafe in building B, or by sending a PDF file by email
to him. Your solutions can be written in Swedish or English.

1. Problem 2 of Homework 4 from the textbook (p. 304), extended.


The operation of shuffle is important in the theory of concurrent sys-
tems. If x, y , we write x || y for the set of all strings that can be
obtained by shuffling strings x and y together like a deck of cards; for
example

ab || cd = { abcd, acbd, acdb, cabd, cadb, cdab }.

The set x || y can be defined by induction:

|| y = {y},
x || = {x},
xa || yb = (x || yb){a} (xa || y){b}.

The shuffle L1 || L2 of two languages L1 and L2 is the set of all strings


obtained by shuffling a string from L1 with a string from L2 :
[
L1 || L2 = x || y
x L1
y L2
For example,

{ab} || {cd, e} = {abe, aeb, eab, abcd, acbd, acdb, cabd, cadb, cdab }.

1
(a) What is L = (01) || (10) ? Give NFAs for the languages (01)
and (10) . Using them construct an NFA for (01) || (10) .
(b) Show that if L1 , L2 are regular languages then so is L1 || L2 . Do
this by describing a general method of constructing an NFA for
L1 || L2 out of NFAs for L1 and L2 .
Hint from the textbook: Put a pebble on a machine for L1 and
one on a machine for L2 . Guess nondeterministically which pebble
to move. Accept if both pebbles occupy accept states.
(c) Applying standard methods construct a minimal DFA for L.
(d) Consider the equivalence relation RL on (thus RL )
defined by: xRL y if and only if for all z , xz L iff yz L.
What is the index (the number of equivalence classes) of RL ?
Describe precisely at least one of the equivalence classes of RL (by
giving an automaton, regular expression, etc, or in words).

2. Consider the finite automaton a


given by the diagram. Is the
automaton deterministic? a,b
A B
Using a standard method con-
struct a regular expression for b
a b
the language defined by the
automaton.
C a D b

3. Let r, s be arbitrary regular expressions. Which of these pairs of regular


expressions denote the same languages?

(r + s) r + s
r r (r + s) (r s )
rr r r (r + s) (r s)
r(sr) (rs) r (r + s) (r s) r

4. At the lectures we presented a construction of an NFA for the union


L(N ) L(N ) of the languages accepted by two given NFA. We
simply took N and N together: the start states were the union of
the start states of N and N and the final states were the union of
the final states of N and N This way the new automaton consists
of two disconnected parts. An alternative is to introduce one new

2
initial state s and one new final state f , with -transitions from s to
the initial states of N , N , and from the final states of N , N to f .
Another idea would be to glue together both initial states of N , N
into a single state. (The same may be done with the final states of
N , N .) Find out whether this idea is correct. In other words, does it
produce an automaton which accepts the language L(N ) L(N )?
5. Which of the following languages are regular? In each case give a
construction/proof to justify your claim.
Hint: Be clever. You are not required to construct an automaton or a
regular expression for each regular language below. And in some cases this
may require really too much work.

(a) L1 = { x {a, b} | #a(x) 2 mod 7 }.


(#a(x) denotes the number of occurrences of a in x).
(b) L2 {a, b, c} is the set of those strings in which every a is im-
mediately preceded by b.
(c) L3 {a, b, c} is the set of those strings in which some a is not
preceded (immediately) by b.
(d)
#b(x) is even, #a(x) 2 mod 7,





L4 = x {a, b, c} x contains abc as a substring, .
x does not contain cba as a substring

(e) Let 0 = {0, 1, 2, . . . , 9} and = 0 { a }. Let x denote the


number corresponding to a string x 0 (in the usual decimal
notation for numbers).
L5 = { xay | x, y 0 , x = 3 y + 2 }
(f) L6 = { x {a, b} | #a(x) 6= #b(x) + 7 }.
(g) L7 is the homomorphic image of L6 under the homomorphism
h : {a, b} {c, d} such that h(a) = cd, h(b) = cd.

6. (Optional: solving this problem you may skip one of the items of the
previous problem). Prove that the set of programs of your favourite
programming language is not regular.
Hint: To make the proof manageable, you may use a homomorphism h
which maps the programming language onto some simple language L .
Construct h in such a way that L is not regular and that this fact is
easy to prove. It may be convenient if h maps most of the symbols
into .

Das könnte Ihnen auch gefallen