So I'm trying to find an unambiguous expression for M where M is the set of ternary strings where each block of 1s has length at least 3 and every block of 2s has odd length.Where ternary strings are of
{1,2,3}*
I started with the expression
(0*11(1)*(22)*)*
but found a contradiction as 11.1111 and 1111.11 can both be obtained how can I change my expression to make it express the question above
The final answer is very complicated, so I will need to employ some shortcuts. Introduce the following shorthand:
These represent nonempty legal blocks of $0$s, $1$s and $2$s. Next, let
Here, the $+$'s represent "or," while $\varepsilon$ represents the empty string. $W$ represents any legal string which only involves $1$s and $2$s, and which has at least one $1$. Now, let $A$ be an expression for a legal string which ends in $0$. You can show that
Then, letting $B$ represent legal strings ending in $1$, you can show
and furthermore, letting $C$ represent legal strings ending in $2$, that
Finally, the expression you want is
You can combine all of these substitutions to get a string involving
ε,0,1,2,+and*alone, but it would be super complicated!