recursive definition odd length strings

2.9k Views Asked by At

Given the alphabet {aaa bbb}, give a recursive definition for the language that only contains odd length strings. must be constructive definition we are suppose to treat aaa as one letter and bbb as one letter

this is what I have so far, but I feel that I am missing something

We will represent our language with L    
Rule#1: aaa,bbb is in L 
Rule#2: if w is in L, then so are
                (i): waaaw
                (ii): wbbbw

thanks

4

There are 4 best solutions below

5
On BEST ANSWER

Here's a hint.

You see that $aaa$ and $bbb$ are in $L$.

You also see that one way to guarantee that you have an odd-length string is to combine three odd-length strings.

Given just your two starting strings above, what is the next-largest string length you can create? How can you combine your two starting strings to cover your choices? Can you generalize this?

0
On

Try to think about how new words can be reached from shorter ones. Hint: The length has to be odd, so it would be helpful to increase lengths by two in each step. Now, how can you assure you get all words of length n+2 if you already have the words of length n in your language. (It is a bit like formal induction, i.e. base case aaa and bbb which you already have and then the inductive step going from n to n+2.)

0
On

It looks like your language is $$(\{aaa, bbb\}\{aaa, bbb\})^*\{aaa, bbb\} = \{aaaaaa, aaabbb, bbbaaa, bbbbbb\}^*\{aaa, bbb\}. $$ It is a regular language, so you can find a finite automaton or a regular grammar to describe it.

0
On

We will represent our language with L
Rule#1: $aaa,bbb$ is in $L$ Rule#2: if $w$ is in $L$, then so are

(i): $waaaaaa$

(ii): $wbbbbbb$

(iii):$waaabbb$

(iV):$wbbbaaa $

All possible strings having odd length can be made with these two rules.