Is $\frac12 L$ a regular language? 
Let $L$ be a regular language. Is $\frac{1}{2}L := \left\{ w: \exists_u |u|=|w| \wedge wu\in L \right\}$ regular too?

I think the answer is YES. But I don't know how to prove it. I was trying to modify finite state machine for $L$ to accept $\frac{1}{2}L$ but I failed.
 A: $\newcommand{\reach}{\operatorname{reach}}$Let $D = ( Q , \Sigma, q_0 , \delta , F )$ be a DFA accepting $L$.
Note that if $S \subseteq Q$, then the set $$\reach ( S ) = \{ q \in Q : ( \exists q^\prime \in S ) ( \exists \mathtt{b} \in \Sigma ) ( q^\prime = \delta ( q , \mathtt{b} ) ) \}$$ is the set of all states of $D$ from which some state in $S$ is reachable after reading one input symbol.  In general, $\reach^n ( S )$ is the set of all states of $D$ from which a state in $S$ is reachable after reading some string of length $n$.  In particular, $\reach ( F )$ is the set of all states that are one input symbol away from an accept state, and in general $\reach^n ( F )$ is the set of all states from which an accepting state is reachable by reading some string of length $n$.
We define a second DFA $D^\prime = ( Q^\prime , \Sigma , q_o^\prime , \delta^\prime , F^\prime )$ as follows:  


*

*$Q^\prime = Q \times \mathcal{P} ( Q )$;

*$q_0^\prime = \langle q_0 , F \rangle$;

*$\delta^\prime : Q^\prime \times \Sigma \to Q^\prime$ is defined by $$ \delta^\prime ( \langle q , S \rangle , \mathtt{a} ) = \langle \delta ( q , \mathtt{a} ) , \reach ( S )  \rangle$$

*$F^\prime = \{ \langle q , S \rangle \in Q^\prime : q \in S \}$.


By induction one can show that if $D^\prime$ is in state $\langle q , S \rangle$ after reading a length $n$ string $w$, then $q$ is the state that $D$ is in after reading $w$, and $S = \reach^n ( F )$ is the set of states from which an accepting state of $D$ is reachable by reading a string of length $n$.  If, in addition, $\langle q , S \rangle \in F^\prime$, then taking any length $n$ string $u$ witnessing that $q \in S = \reach^n (F)$ it follows that $wu \in L$ and clearly $|u| = |w|$.
A: For each state of the automaton $S$, you need to know in advance the set $L(S)$ of possible lengths of suffixes that will accept the word built so far.
I think this set is ultimately periodic, by which I mean that there are lengths $n(S)$ and $t(S)$ such that forall $m \ge 0$, $n(S)+m \in L(S) \iff n(S)+m+t(S) \in L(S)$, which means that you only have to remember precisely the length of $u$ up to $n(S)$ or modulo $t(S)$ to decide if, from state $S$, there is a suffix of the same length as $u$ that accepts the word.
Doing this for every state, pick $n = \max n(S)$ and $t = \text{lcm}\; t(S)$ : you only need to remember the length of $u$ up to $n$ or modulo $t$, independantly of the state you are in.
Now you can write a new automaton who remembers this (finite) information on the length $l$ of $u$ while simulating the original automaton, and accepting $(S,l)$ if and only if $l \in L(S)$

Another (much simpler) way is to make a nondeterministic automaton that simulates the original automaton on $u$ and the automaton going in reverse on $v$, simultaneously, and accepts when it finds two words $(u,v)$ landing on the same state.
The states of the new automaton is a couple of states (one for the $u$ process and one for the $v$ process). Put a transition labeled $a$ from $(q_1,q_2)$ to $(q'_1,q'_2)$ if and only if there is a transition labeled $a$ from $q_1$ to $q'_1$ and there is any transition from $q'_2$ to $q_2$ (in the original automaton). Finally, the initial states are the states of the form $(i,f)$ with initial $i$ and final $f$, and the final states are those of the form $(q,q)$.
