Comp Sheet2B
Comp Sheet2B
2024/2025 ﺍﻻﺳﻡ
Theory of Computations
ﺍﻟﺭﻗﻡ
SHHET-2
ﺍﻟﺘﺨﺼﺺ
(i) The language {w| w ϵ {a, b}*, w has an odd number of b's}.
(ii) The language {w | w ϵ {a, b}*, w has an even number of b's}.
(iii) The language {w| w ϵ {a, b}*, w has an even number of b's and odd number of a's}.
Q.3 How many minimum number of states are required in the DFA (over the alphabet {a, b}) accepting all the strings
with the number of a's divisible by 4 and number of b's divisible by 5?
(a) 20 (b) 9
(c) 7 (d) 15
Q.4 How many states does the DFA constructed for The set of all strings ending with "00", have?
(a) 2 (b) 3
(c) 4 (d) 5
Q.5 The transition function of DFA from one state to another on a given input symbol w is a function Q x Σ* to
(a) 2Q (b) Q
(c) Q' (d) Q2
1
Q.7 Consider the machine M shown below:
a,b
a,b
L(M) = ?
Q.10 Consider the FA shown in the figure given below, where "-" is the start and "+" is the ending state. The language
accepted by the FA is
2
Theorem 5.9 Closure Properties of Büchi Automata
Theorem and Proof: The Büchi-acceptable languages (like the regular languages) are closed under:
• Concatenation with a regular language: if L1 is a regular language and L2 is a Büchi-acceptable language, then L1L2
is Büchi-acceptable. The proof is similar to the proof that the regular languages are closed under concatenation
except that, since transitions are not allowed, the machines for the two languages must be “glued together”
differently. If q is a state in the FSM that accepts L1, and there is a transition from q, labeled c, to some accepting
state, then add a transition from q, labeled c, to each start state of the Büchi automaton that accepts L2.
• Union: if L1 and L2 are Büchi-acceptable, then L1 L2 is also Büchi-acceptable. The proof is analogous to the
proof that the regular languages are closed under union. Again, since transitions are not allowed, we must use a
slightly different glue. The new machine we will build will have transitions directly from a new start state to the
states that the original machines can reach after reading one input character.
• Intersection: if L1 and L2 are Büchi-acceptable, then L1 L2 is also Büchi-acceptable. The proof is by construction
of a Büchi automaton that effectively runs a Büchi automaton for L1 in parallel with one for L2.
• Complement: if L is Büchi-acceptable, then L is also Büchi-acceptable. The proof of this claim is less obvious.
It is given in [Thomas 1990].
Further, if L is a regular language, then L is Büchi-acceptable. The proof is analogous to the proof that the regular
languages are closed under Kleene star, but we must again use the modification that was used above in the proof of
closure under concatenation.
◼
Büchi automata are useful as models for computer systems whose properties we wish to reason about because a set of
important questions can be answered about them. In particular, Büchi automata share with FSMs the existence of
decision procedures for all of the properties described in the following theorem:
Proof: The proof of each of these claims can be found in [Thomas 1990].
◼
5.13 Exercises
1) Give a clear English description of the language accepted by the following DFSM:
1 b 2 a 3
a a b a a
4 b 5 6
a, b
3) Consider the children’s game Rock, Paper, Scissors . We’ll say that the first player to win two rounds wins the
game. Call the two players A and B.
a) Define an alphabet and describe a technique for encoding Rock, Paper, Scissors games as strings over .
(Hint: each symbol in should correspond to an ordered pair that describes the simultaneous actions of A
and B.)
b) Let LRPS be the language of Rock, Paper, Scissors games, encoded as strings as described in part (a), that
correspond to wins for player A. Show a DFSM that accepts LRPS.
a
a
b
b
a
b
7) Show an FSM (deterministic or nondeterministic) that accepts L = {w {a, b, c}* : w contains at least one
substring that consists of three identical symbols in a row}. For example:
• The following strings are in L: aabbb, baacccbbb.
• The following strings are not in L: , aba, abababab, abcbcab.
8) Show a DFSM to accept each of the following languages. The point of this exercise is to see how much harder it
is to build a DFSM for tasks like these than it is to build an NDFSM. So do not simply build an NDFSM and
then convert it. But do, after you build a DFSM, build an equivalent NDFSM.
a) {w {a,b}* : the fourth from the last character is a}.
b) {w {a, b}* : x, y {a,b}* : ((w = x abbaa y) (w = x baba y))}.
9) For each of the following NDFSMs, use ndfsmtodfsm to construct an equivalent DFSM. Begin by showing the
value of eps(q) for each state q:
a)
1
q0 q1 0 q2
1 1 1
0
q3 0 q4 q5
b) a, b
q0 a q1 a, b q2 a, b q3 a, b q4
c) b
a
a
q0 q1 a q4
b a a b
a
q3 b q2 b q5
q1 q2 a q3
b b
q4 q5
a
q6 q7
b b
a
q1 a q2 q3
a
b b b
b b
a
q4 a q5 q6
a
13) Construct a deterministic finite state transducer with input alphabet {a, b} for each of the following tasks:
a) On input w, produce 1n, where n = #a(w).
b) On input w, produce 1n, where n = #a(w)/2.
c) On input w, produce 1n, where n is the number of occurrences of the substring aba in w.
14) Construct a deterministic finite state transducer that could serve as the controller for an elevator. Clearly describe
the input and output alphabets, as well as the states and the transitions between them.
15) Consider the problem of counting the number of words in a text file that may contain letters plus any of the
following non-letter characters:
Describe a very simple finite-state transducer that reads the characters in the file one at a time and solves the
word-counting problem. Assume that there exists an output symbol with the property that, every time it is
generated, an external counter gets incremented.
16) Real traffic light controllers are more complex than the one that we drew in Example 5.29.
a) Consider an intersection of two roads controlled by a set of four lights (one in each direction). Don’t worry
about allowing for a special left-turn signal. Design a controller for this four-light system.
b) As an emergency vehicle approaches an intersection, it should be able to send a signal that will cause the
light in its direction to turn green and the light in the cross direction to turn yellow and then red. Modify
your design to allow this.
17) Real bar code systems are more complex than the one that we sketched in Example
5.31. They must be able to encode all ten digits, for example. There are several
industry-standard formats for bar codes, including the common UPC code found on
nearly everything we buy. Describe a finite state transducer that reads the bars and
outputs the corresponding decimal number.
0 12345 67890 5
18) Extend the description of the Soundex FSM that was started in Example 5.33 so that it can assign a code to the
name Pfifer. Remember that you must take into account the fact that every Soundex code is made up of exactly
four characters.
19) Consider the weather/passport HMM of Example 5.37. Trace the execution of the Viterbi and forward algorithms
to answer the following questions:
a) Suppose that the report ###L is received from Athens. What was the most likely weather during the time of
the report?
b) Is it more likely that ###L came from London or from Athens?
20) Construct a Büchi automaton to accept each of the following languages of infinite length strings:
a) {w {a, b, c} : after any occurrence of an a there is eventually an occurrence of a b}.
b) {w {a, b, c} : between any two a’s there is an odd number of b’s}.
c) {w {a, b, c} : there never comes a time after which no b’s occur}.
21) In C 685, we describe the use of statecharts as a tool for building complex systems. A statechart is a hierarchically
structured transition network model. Statecharts aren’t the only tools that exploit this idea. Another is Simulink®
, which is one component of the larger programming environment Matlab ® . Use Simulink to build an FSM
simulator.
22) In C 696, we describe the Alternating Bit protocol for handling message transmission in a network. Use the FSM
that describes the sender to answer the question, “Is there any upper bound on the number of times a message
may be retransmitted?”
23) In C 717, we show an FSM model of a simple intrusion detection device that could be part of a building security
system. Extend the model to allow the system to have two zones that can be armed and disarmed independently
of each other.