Building a DFA from another DFA.

automataformal-languages

Let the language that the DFA accepts have a different definition.
A word is in the language if and only if when we finish reading it we reach an accepting state AND atleast one time passed through an accepting state while reading it.
For example if we have an automaton with two states $q_0$ and $q_1$ where $q_1$ is an accepting state, and $\delta(q_0,a)=q_1, \delta(q_1,a)=q_0$.
The word $a$ is not accepted because we didn't pass through any accepting states reaching $q_1$, but $aaa$ is accepted.

Given a DFA that accepts a language in this way, build a DFA that accepts the same language in the normal definition.

Here's my work until now, still couldn't come up with an approach just set the start and been stuck here for a long time trying different stuff:
Let $A=(\sum,Q_A,q_{0A},F_A, \delta_A)$ be a DFA that accepts the language $L$ in the mentioned way, we need to build a DFA $B=(\sum,Q_B,q_{0B},F_B, \delta_B)$ that accepts the language according to the normal definition.

if $w\in L$ is a word that is accepted in $A$, then it must pass through atleast 1 state in $F_A$ before reaching the end in $F_A$ too.

I couldn't really come out with information about $F_B$, I'm finding it hard to jump from $A$ to $B$, I am trying to base $F_B$ definition on $F_A$.

I would really appreciate any help, thanks in advance!

Best Answer

Equivalently, you want a DFA for $L\cap(L\Sigma^+)$ given a DFA $A$ that recognizes $L$.

You can make a new DFA where each state is the pair $$(\text{set of states of A previously met},\text{current state in A})$$ Formally \begin{align}&\Sigma_B=\Sigma_A\\ &Q_B=\{(X,y)\,:\, X\subseteq Q_A\land y\in Q_A\}\\ &q_{0B}=(\varnothing, q_{0A})\\ &F_B=\{(U,y)\,:\, U\cap F_A\ne\varnothing\land y\in F_A\}\\ &\delta_B((X,y),c)=(X\cup\{y\}, \delta_A(y,c))\end{align}

It's quite clear that this is correct and it's quite clear that the DFA I've described may have states that can't be reached from the starting state.

Related Question