Let $\Sigma_n = \{0, 1, ... , n-1\}$. Suppose $L \subseteq$ $\Sigma^*_n$, and let
$\mathcal{L}(L) = \{ x \in L : x \text{ is the lexicographically largest among all strings of length } |x| \text{ in } L \}$. For example, $\mathcal{L}(\{0,1\}^*) = 1^*$ and $\mathcal{L}(\epsilon \cup 1(0 \cup 01)^*) = (10)^*(\epsilon \cup 1)$. Prove that if $L$ is regular, then so is $\mathcal{L}(L)$.
Below is my attempt at proving this.
Define alphabet $\gamma = \{(n_1,n_2) : n_1,n_2 \in \Sigma_n\}$. Define morphism $h : \gamma^* \to \Sigma^*_n$ as $h((n_1,n_2)) = n_1n_2$ for all $(n_1,n_2) \in \gamma$.
Define morphism $h_1 : \gamma^* \to \{1 \cup 2\}^*$ as
$h_1((n_1,n_2)) = \left\{ \begin{array}{lr} 1 & \quad \text{ if $n_1 > n_2$}\\ 2 & \quad \text{ if $n_2 > n_1$}\\ \epsilon & \quad \text{ if $n_1 = n_2$} \end{array} \right.$
Define the substitution $s : \gamma* \to \mathcal{P}(\Sigma^*_n)$ to be $s((n_1,n_2)) = \{n_1\}$ for all $(n_1,n_2) \in \gamma$
Perfect shuffle $L$ with itself. Call the resulting language $L_{ps}$.
Compute $L_1 = s(h_1^{-1}(1\{1,2\}^* \cup \epsilon) \space \cap h^{-1}(L_{ps}))$
Repeat 1 and 2 with $L_1$
Repeat 1, 2, 3 indefinitely. The resulting language $L_1$ will be $\mathcal{L}(L)$.
I think the problem with the above is that I'd have to repeat these steps infinitely many times for the case that $L$ is infinite.