proving regular language

31 Views Asked by At

let $L$ be a language over the alphabet $\{a,b\}$ that maintains that for each $w \in L$ ,the difference in absolute between the number of apearences of the letter $a$ and the number of apearences of the letter $b \,$ in every prefix of $w$ is at most $10$.

For example:

$ababababa \in L$

$abbbbbbbbbbbb \not\in L$

1

There are 1 best solutions below

0
On BEST ANSWER

$\Sigma=\{a,b\}$

For $w\in \Sigma^*$, define $v(w)=|w|_b - |w|_a$ (the number of $b$s minus the number of $a$s). What can you say about $v(L)$?

$v(L)$ is finite. So you can encode the value $v(u)$ of the prefix $u$ of the word you're reading in the states of an automaton, one state per value in $v(L)$. Now how do you define the transitions?

-

You define them using $v(wa)=v(a)-1$ and $v(wb)=v(w)+1$. Note that the reason this works is that if $uv\in L$, then $u\in L$.