If I have a deterministic finite automaton (DFA) with a language $W$, and I need to create another DFA that returns all the strings that are a concatenation of an even number of strings in $W$, how would I solve this?
I was considering an approach where I alternate between accepted even multiples of the DFA and unaccepted odd multiples, and essentially connect two copies of the original DFA together to create the even-DFA. However, if I have multiple accept states within the original language this would complicate things as I would need to allow connections from all of these states, and would then need to consider the presence of self-loops.
This will be implemented in Haskell, but insight either from the logic point of view or the coding point of view would be greatly appreciated.