COS2601
ASSIGNMENT 2
SEMESTER 1
2021
, Question 1
A recursive definition for the language EVENnotBAB over the alphabet = {a b} must be compiled where
EVENnotBAB consists of all words of even length and not containing the substring bab.
Give (i) an appropriate universal set,
(ii) the generator(s) of EVENnotBAB, and
(iii) an appropriate function on the universal set, and then
(iv) use these concepts to write down a recursive definition of the language EVENnotBAB.
Answer
(i) The set Σ = {a b}* will be suitable because it contains, along with other words, all the words that
are in the language EVENnotBAB.
(ii) The generators should be of even length and should not contain the substring bab. One possible
choice is . Another possible choice is , aa, ab, ba and bb. Remember that zero is an even
number.
(iii) The function CONCAT, as defined in the notes in the learning units, will be suitable.
(iv) We give two possible recursive definitions. Note that all words in EVENnotBAB should have an
even number of letters. The generators all have an even number of letters; therefore, to keep the
length of new words even, we concatenate two letters at a time.
EVENnotBAB is the smallest subset of {a b}* such that
EVENnotBAB and
if w EVENnotBAB, then also
CONCAT(w, aa) EVENnotBAB,
if w EVENnotBAB and w does not end on a ba, then
CONCAT(w, bb), CONCAT(w, ba) EVENnotBAB and
if w EVENnotBAB and w does not end on a b, then
CONCAT(w, ab) EVENnotBAB
or
Rule 1: , aa, ab, ba, bb EVENnotBAB.
Rule 2: If w EVENnotBAB, then also
CONCAT(aa, w) EVENnotBAB,
if w EVENnotBAB and w does not start with an ab, then
CONCAT(bb, w), CONCAT(ab, w) EVENnotBAB,
2
ASSIGNMENT 2
SEMESTER 1
2021
, Question 1
A recursive definition for the language EVENnotBAB over the alphabet = {a b} must be compiled where
EVENnotBAB consists of all words of even length and not containing the substring bab.
Give (i) an appropriate universal set,
(ii) the generator(s) of EVENnotBAB, and
(iii) an appropriate function on the universal set, and then
(iv) use these concepts to write down a recursive definition of the language EVENnotBAB.
Answer
(i) The set Σ = {a b}* will be suitable because it contains, along with other words, all the words that
are in the language EVENnotBAB.
(ii) The generators should be of even length and should not contain the substring bab. One possible
choice is . Another possible choice is , aa, ab, ba and bb. Remember that zero is an even
number.
(iii) The function CONCAT, as defined in the notes in the learning units, will be suitable.
(iv) We give two possible recursive definitions. Note that all words in EVENnotBAB should have an
even number of letters. The generators all have an even number of letters; therefore, to keep the
length of new words even, we concatenate two letters at a time.
EVENnotBAB is the smallest subset of {a b}* such that
EVENnotBAB and
if w EVENnotBAB, then also
CONCAT(w, aa) EVENnotBAB,
if w EVENnotBAB and w does not end on a ba, then
CONCAT(w, bb), CONCAT(w, ba) EVENnotBAB and
if w EVENnotBAB and w does not end on a b, then
CONCAT(w, ab) EVENnotBAB
or
Rule 1: , aa, ab, ba, bb EVENnotBAB.
Rule 2: If w EVENnotBAB, then also
CONCAT(aa, w) EVENnotBAB,
if w EVENnotBAB and w does not start with an ab, then
CONCAT(bb, w), CONCAT(ab, w) EVENnotBAB,
2