$k$-Universality of Regular Languages Revisited

Extracted source text · arXiv 2503.18611

% This is samplepaper.tex, a sample chapter demonstrating the
% LLNCS macro package for Springer Computer Science proceedings;
% Version 2.21 of 2022/01/12
%
\documentclass[runningheads]{llncs}
%
\usepackage[T1]{fontenc}
% T1 fonts will be used to generate the final print and online PDFs,
% so please use T1 fonts in your manuscript whenever possible.
% Other font encondings may result in incorrect characters.
%
\usepackage{graphicx}
% Used for displaying a sample figure. If possible, figure files should
% be included in EPS format.
%
% If you use the hyperref package, please uncomment the following two lines
% to display URLs in blue roman font according to Springer's eBook style:
%\usepackage{color}
%\renewcommand\UrlFont{\color{blue}\rmfamily}
%\urlstyle{rm}
%

% things we inserted
\usepackage{amsmath,amssymb,enumitem}
%\usepackage{amsthm}
\usepackage[utf8]{inputenc}
\usepackage{todonotes}

\usepackage{thmtools}
\usepackage{chngcntr}

\usepackage{tikz}
\usepackage{float}
\usepackage{cancel}
\usepackage{algorithm}
\usepackage{algpseudocode}

%\lstset{emph={%  
%		while,do,int,goto,done,each,for,all,set,fi,then,od,or, endwhile, =, :=, ;, +, -, *, >, <,
%		push, pop, pass, end, repeat, until%
%	},emphstyle={\bfseries}%
%}

\usetikzlibrary{arrows,automata}

\def\N{\mathbb{N}}

\def\ed{wzb}
\def\ta{\mathtt{a}}
\def\tb{\mathtt{b}}
\def\tc{\mathtt{c}}
\def\td{\mathtt{d}}
\def\tn{\mathtt{n}}
\def\tx{\mathtt{x}}
% 
\DeclareMathOperator{\Recons}{Recons}
\DeclareMathOperator{\ScatFact}{ScatFact}
\DeclareMathOperator{\Subseq}{SubSeq}
\DeclareMathOperator{\Univ}{Univ}
\DeclareMathOperator{\PerfUniv}{PUniv}
\DeclareMathOperator{\PUniv}{PUniv}
\DeclareMathOperator{\Fact}{Fact}
\DeclareMathOperator{\MinClos}{MinClos}
\DeclareMathOperator{\letters}{alph}
\DeclareMathOperator{\regexletters}{OAlph}
\DeclareMathOperator{\lex}{lex}
\DeclareMathOperator{\suff}{suff}
\DeclareMathOperator{\can}{can}
\DeclareMathOperator{\Swap}{Swap}
\DeclareMathOperator{\calc}{calc}
\DeclareMathOperator{\firstAfter}{firstAfter}
\DeclareMathOperator{\ar}{ar}
\DeclareMathOperator{\modus}{m}
\DeclareMathOperator{\m}{m}
\DeclareMathOperator{\rest}{r}
\def\r{\operatorname{r}}
\DeclareMathOperator{\inner}{in}
\renewcommand{\alph}{alph}
\DeclareMathOperator{\labels}{label}
\newcommand{\poly}{poly}
\DeclareMathOperator{\al}{alph}

% 
\def\nth#1{#1$^{\text{th}}$}

\newcommand{\NIL}{\mathit{NIL}}
\newcommand{\COMB}{\mathit{COMB}}
\newcommand{\DEF}{\mathit{DEF}}
\newcommand{\SYDEF}{\mathit{SYDEF}}
\newcommand{\COMM}{\mathit{COMM}}
\newcommand{\CIRC}{\mathit{CIRC}}
\newcommand{\SUF}{\mathit{SUF}}
\newcommand{\PRE}{\mathit{PRE}}
\newcommand{\INF}{\mathit{INF}}
\newcommand{\NC}{\mathit{NC}}
\newcommand{\SF}{\mathit{SF}}
\newcommand{\UF}{\mathit{UF}}
\newcommand{\FIN}{\mathit{FIN}}
\newcommand{\MON}{\mathit{MON}}
\newcommand{\PS}{\mathit{PS}}
\newcommand{\ORD}{\mathit{ORD}}
\newcommand{\STAR}{\mathit{STAR}}
\newcommand{\COM}{\mathit{COM}}
\newcommand{\LCOM}{\mathit{LCOM}}
\newcommand{\RCOM}{\mathit{RCOM}}
\newcommand{\TCOM}{\mathit{2COM}}
\newcommand{\REG}{\mathit{REG}}
\newcommand{\Suf}{\mathit{Suf}}
\renewcommand{\epsilon}{\varepsilon}

\tikzstyle{edgeLabel}=[inner sep=0.5mm,fill=white,text=black]

%\theoremstyle{definition}
%\newtheorem{problem}[definition]{Problem}

\newcommand{\todofpa}[1]{\todo[color=blue!20,inline]{#1}}
\newcommand{\todofda}[1]{\todo[color=green!20,inline]{#1}}
\newcommand{\todoah}[1]{\todo[color=violet!30,inline]{#1}}

% ARCHIVE / PAPER VERSION CONTROLER
\newif\ifpaper
%\papertrue % SET TRUE FOR PAPER VERSION
\paperfalse % SET FALSE FOR ARCHIVE VERSION

\begin{document}
	%
	\title{$k$-Universality of Regular Languages Revisited}
	%
	%\titlerunning{Abbreviated paper title}
	% If the paper title is too long for the running head, you can set
	% an abbreviated paper title here
	%
	\author{Duncan Adamson\inst{1}\orcidID{0000-0003-3343-2435} \and
		Pamela Fleischmann\inst{2}\orcidID{0000-0002-1531-7970} \and
		Annika Huch\inst{2}\orcidID{0009-0005-1145-5806} \and
		Tore Koß\inst{3}\orcidID{0000-0001-6002-1581} \and
		Florin Manea\inst{3}\orcidID{0000-0001-6094-3324}}
	%
	\authorrunning{D. Adamson et al.}
	% First names are abbreviated in the running head.
	% If there are more than two authors, 'et al.' is used.
	%
	\institute{School of Computer Science, University of St Andrews, UK \email{duncan.adamson@st-andrews.ac.uk} \and
		Department of Computer Science, Kiel University, Germany
		\email{\{fpa,ahu\}@informatik.uni-kiel.de} \and
		Department of Computer Science, University of Göttingen, Germany\\
		\email{\{tore.koss,florin.manea\}@cs.uni-goettingen.de}}
	%
	\maketitle              % typeset the header of the contribution
	%
	\begin{abstract}
		\input{abstract}
		\keywords{String Algorithms \and Regular Languages \and Subregular Languages \and Regular Expressions \and Finite Automata \and Subsequences \and Universality}
	\end{abstract}
	\newpage
	
	\setcounter{page}{1}
	\section{Introduction}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\input{introduction}
	
	\section{Preliminaries}\label{prelims}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\input{prelims}
	
	\input{general}
	
%	\section{Acyclic Automata}
	\label{sec:acyclic}
	\input{acyclic}
	
%	\vspace*{-15pt}\subsubsection*{Regular Expressions.}
	\label{sec:regex}
	\input{regex}
	
%	\section{Subregular Languages}
%	\label{sec:subregular}
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	\input{general}
	
%	\input{results}
	
%	\section{Contextual Languages}
%	\label{sec:contextual}
%	\input{contextual}

	
	% \section{Decision Problems}\label{npc}
	% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	% \input{nphardness}
	% 
	% \section{Counting and Ranking}
	% \label{sec:counting}
	% 
	% \input{countingandranking}
	
%	\section{Conclusion}\label{conc}
%	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	\input{conclusion}
%	
%	\todoah{add funding}
%	\begin{credits}
%		\subsubsection{\ackname} Duncan Adamson's work was funded by the Leverhulme Trust via the Leverhulme Research Centre for Functional Material Design. Tore Koß’ work was supported by the DFG project number 389613931. Florin Manea’s work was supported by the DFG Heisenberg-project number 466789228.
%	\end{credits}
	
	\newpage
	%
	% ---- Bibliography ----
	%
	% BibTeX users should specify bibliography style 'splncs04'.
	% References will then be sorted and formatted in the correct style.
	
	 \bibliographystyle{splncs04}
	 \bibliography{refs}
	
	 \ifpaper
	 
	 \newpage
	 \appendix
	 \section{Computational Model}\label{sec:computational_model}
	 \input{compmodel}
	 \section{Further Examples}\label{sec:furtherdefs}
	 \input{furtherdefs}
	 \section{Proofs}\label{sec:appendixproofs}
	 \input{appendixproofs}
	 \else
	 \fi
	
\end{document}

A subsequence of a word $w$ is a word $u$ such that $u = w[i_1] w[i_2] \cdots w[i_k]$, for some set of indices $1 \leq i_1 < i_2 < \dots < i_k \leq \vert w \vert$. A word $w$ is \emph{$k$-subsequence universal} over an alphabet $\Sigma$ if every word over $\Sigma$ up to length $k$ appears in $w$ as a subsequence. In this paper, we revisit the problem $k$-ESU of deciding, for a given integer $k$, whether a regular language, given either as nondeterministic finite automaton or as a regular expression, contains a $k$-universal word.  [Adamson et al., ISAAC 2023] showed that this problem is NP-hard, even in the case when $k=1$, and an FPT algorithm w.r.t. the size of the input alphabet was given. In this paper, we improve the aforementioned algorithmic result and complete the analysis of this problem w.r.t. other parameters. That is, we propose a more efficient FPT algorithm for $k$-ESU, with respect to the size of the input alphabet, and propose new FPT algorithms for this problem w.r.t.~the number of states of the input automaton and the length of the input regular expression. We also discuss corresponding lower bounds. Our results significantly improve the understanding of this problem. 

%
%  study the intersection between the notion of $k$-subsequence universality and two restricted classes of languages, namely subregular languages. Subregular languages are a subset of regular languages imposing restrictions that limit the languages in ways modelled on natural languages. Along with an FPT algorithm that solves the problem of deciding whether there exists a $k$-universal word within a given language ($k$-ESU problem) that depends on the number of states of the representing automata, we provide a comprehensive set of results on the hardness of determining, for some given language $L$, what the maximum $k$ is such that $L$ contains a $k$-subsequence universal word. We show a set of positive and negative results, splitting these languages into those for which the problem can be easily solved, and those for which it is NP-hard. Further, we show that the problem of determining whether a regular language represented by a regular expression contains a $k$-universal word is  NP-complete by a reduction from 3-SAT.
%\todo{no more than 12 pages, excluding references and the front page(s) (authors, affiliation, keywords, abstract, …), presenting original research on the theory of computer science. Technical details necessary for a proper scientific evaluation of a submission must be included in the 12-page submission or in a clearly labelled appendix, to be consulted at the discretion of program committee members}
Words and subsequences are two fundamental and heavily studied concepts in the field of combinatorics on words. A subsequence of a given word $w$ is a word $u$ that is obtained by deleting some letters of $w$ while preserving the order of letters in $w$ for the non-deleted ones. 
For instance, the word $\mathtt{subregularuniversality}$ has the scattered factors $\mathtt{glue}, \mathtt{guilty}, \mathtt{surreality}$ while $\mathtt{versailles}$ is not a scattered factor since the letters do not occur in the same order as in the whole word. \looseness=-1

Within theoretical computer science, subsequences were considered mainly in two areas. On the one hand, there are many algorithmic and complexity problems arising from this object, e.g., in problems such as the longest or shortest common subsequence or supersequence problems \cite{chvatal1975longest,Hirschberg77,HuntS77,Maier78,MasekP80,NakatsuKY82,Baeza-Yates91,BergrothHR00,BringmannC18,BringmannK18,AbboudEtAl2014,AbboudEtAl2015,AbboudRubinstein2018}, or matching and analysis problems related to the sets of subsequences occurring in a word \cite{hebrard1991algorithm,simon2003words,tronicek2003common,DBLP:journals/jda/CrochemoreMT03,barker2020scattered,day2021edit,fleischer2018testing,KimKH22,gawrychowski2021simons,kosche2021absent,DBLP:conf/rp/FleischmannKKMNSW23}; see also the survey \cite{Kosche2022SubsequenceSurvey}. On the other hand, subsequences are intensely studied objects in combinatorics on words, formal languages, automata theory and logics, especially with respect to their strong relation to piecewise-testable languages \cite{KarandikarKS15,karandikar2016height,Simon72,simon1972thesis}, or subword orders and downward closures \cite{halfon2017decidability,DBLP:conf/csr/Kuske20,DBLP:conf/fossacs/KuskeZ19,zetzsche2016complexity,DBLP:conf/lics/Zetzsche18}.
Such theoretical results found applications in a wide number of fields including bioinformatics \cite{han2020novel,shikder2019openmp}, and modelling concurrency \cite{shaw1978software}. Still on the applicative side, a new research direction, originating in database theory \cite{artikis2017complex,Kleest-Meissner22,Kleest-Meissner23,FrochauxK23}, deals with constrained-subsequences of strings, where the substrings occurring between the positions of the subsequence are subject to regular or length constraints; a series of algorithmic and complexity results related to this setting were obtained \cite{DayKMS22,KoscheKMP22,Goettingen2023words,ManeaRS24}. \looseness=-1

The work of this paper is positioned in between the study of algorithmic properties of subsequences and automata and formal language theory. More precisely, we revisit and extend the results of \cite{SchnoebelenV23,regunivpaper,fazekas2024subsequencematchinganalysisproblems}. In the respective works, the authors generalized fundamental algorithmic questions related to the subsequences occurring in a single word to the case of subsequences occurring in (finite or infinite) sets of words represented succinctly by automata accepting these sets or by grammars generating them (i.e., formal languages). In general, two main classes of questions were investigated: for some subsequence-related property of words, given a generative or accepting mechanism for a language, one is interested, on the one hand, whether there is at least one word of the language which fulfils the respective property, or, on the other hand, whether all words of the language fulfil the respective property. The main such subsequence-property approached in \cite{SchnoebelenV23,regunivpaper,fazekas2024subsequencematchinganalysisproblems} is the $k$-universality of words. Formally, a word over an alphabet $\Sigma$ is called \emph{$k$-universal} if its set of subsequences of length $k$ includes every word of length $k$ over $\Sigma$. An extensive literature deals with this concept, mostly from a theoretical perspective \cite{karandikar2016height,schnoebelen2019height,adamson2023words,barker2020scattered,day2021edit,fleischmann2021scattered,fleischmann2023alphabetafactorization,kosche2021absent,SchnoebelenV23}; see \cite{day2021edit,regunivpaper} and the references therein for a detailed discussion of the motivation for the study of $k$-universality. Coming back to our focus, in \cite{regunivpaper}, the authors investigated two decision problems regarding universality, corresponding to the two directions mentioned above. First is the problem of deciding whether there exists a $k$-universal word in a given regular language $L$, specified as a non-deterministic finite automaton, for some given $k$ (for short $k$-ESU for $k$ \textbf{e}xistence \textbf{s}ubsequence \textbf{u}niversality); this problem was shown to be NP-complete, and an FPT algorithm, with respect to the size of the input alphabet, was given for it. Second is the problem whether all words in $L$ are $k$-universal ($k$-USU for $k$ \textbf{u}niversal \textbf{s}ubsequence \textbf{u}niversality); this problem was shown to be solvable in polynomial time. In \cite{fazekas2024subsequencematchinganalysisproblems}, the authors extended the study of these problems for context-free and context-sensitive languages, specified by grammars generating them;  \cite{SchnoebelenV23} discusses similar problems for strings encoded via straight-line programs. In this context, the problem $k$-ESU is the harder and less understood of the two aforementioned problems, so we revisit it in this paper. \looseness=-1

The research direction proposed in \cite{SchnoebelenV23,regunivpaper,fazekas2024subsequencematchinganalysisproblems}, and revisited here, is not completely new. It originates in the famous result of Higman~\cite{higman1952ordering} which states that the downward closure of every language (i.e., the set of all subsequences of the strings of the respective language) is regular; however, an automaton accepting this language is not always computable (e.g., for the class of context-sensitive languages). As downward closures of languages can be seen as structurally-simple yet faithful-enough abstractions of complex (and practically relevant) formal languages, they become useful in practical applications and well studied from a theoretical point of view (see~\cite{zetzsche2016complexity,DBLP:conf/lics/Zetzsche18,AnandZ23} and the references therein). In our setting, downward closures, the fact that they are regular and it is not hard to compute an automaton for them (since we deal with regular languages only), could also be useful in approaching problems such as $k$-ESU. But, as discussed in \cite{fazekas2024subsequencematchinganalysisproblems}, such solutions would be quite inefficient. So, our main aim in revisiting $k$-ESU is to extend the work of \cite{regunivpaper,fazekas2024subsequencematchinganalysisproblems} on it, and identify new, more efficient solutions, as well as a better understanding of the lower bounds for solving this problem. Moreover, as $k$-ESU was already shown to be hard for regular languages (even for finite languages), we also consider first this class of languages in this paper, and leave the investigation of more complex classes of languages as future work.\looseness=-1

%
%
%
%
%
%
%Computing the downward closure of a language is a general (although, often inefficient) way to solve subsequence-matching problems for languages; for instance, we can immediately check, using a finite automaton for the downward closure, if a string occurs as subsequence of a string of the respective language. However, it is often the case that more complex analysis problems regarding the subsequences occurring in the strings of a language cannot be solved efficiently (or, sometimes, at all) using the downward closure; such a problem is to check if a given string occurs as subsequence in all the strings of a language (chosen from a complex enough class, such as the class of context-free languages). 
%
%







\emph{Our Contributions.} Our main results provide a very detailed image of the parametrised complexity of the $k$-ESU problem for regular languages. When the input regular language is given as an NFA, this problem has three parameters: the number $n$ of states of the NFA, the size $\sigma$ of the input alphabet, and the integer $k$. We analyse the complexity of $k$-ESU with respect to all these parameters. As mentioned above, an FPT algorithm w.r.t. $\sigma$ was known from \cite{regunivpaper}; we give here a faster algorithm, which runs in linear time for constant alphabets. We also give here the first FPT algorithm for $k$-ESU w.r.t. $n$, which runs in linear time for NFAs with a constant number of states. As already $1$-ESU is NP-hard (when the input regular language is given as NFA, DFA, or regular expression), we can conclude that, unless P=NP, there is no FPT algorithm, w.r.t. the parameter $k$, solving $k$-ESU. When the input regular language is given as a regular expression of length $n$ over an alphabet of size $\sigma$, we obtain an FPT algorithm w.r.t. $\sigma$; $1$-ESU remains NP-complete in this setting. Finally, based on the lower bounds shown here and in \cite{regunivpaper}, we show that our algorithmic results are tight, from a fine-grained complexity perspective. As far as the used techniques are concerned, we extensively use a graph-theoretical tool box, which allows us to gain new combinatorial insights in the structure of the $k$-ESU problem, and develop efficient methods for solving it. \looseness=-1
\ifpaper
Due to space restrictions, some proofs are only given in Appendix~\ref{sec:appendixproofs}. 
\else
\fi

%In this work, we present efficient algorithms to decide the $k$-ESU problem for acyclic finite automata and provide an NP-reduction from 3-SAT for the $k$-ESU problem on regular expressions. Further, we focused on several subregular languages. First, we investigated subregular languages that have a bounded number of states, presenting an FPT-algorithm on the number of states for the $k$-ESU problem. Further, we continued with other types of subregular languages: For subregular languages with a \emph{simpler} structure w.r.t.~the inclusion relation from all subregular languages we give efficient algorithms to solve the $k$-ESU problem. For more complex subregular languages we transfer the NP-hardness result from \cite{regunivpaper}. 
%%Further, we inspect contextual languages and show that the $k$-ESU problem for external contextual grammars is decidable in polynomial time while the $k$-ESU problem for internal contextual grammars remains open and is conjectured to be NP-hard. 
%See Table \ref{tab:results} for a complete overview of the results.
%\todoah{$\downarrow$ update table later, or delete and use the figure with inclusion properties instead}
%\begin{table}
%	\caption{Overview of the time complexity of the language classes studied here.}
%	\label{tab:results}
%	\begin{tabular}{l|l|l}
%		Language & $k$-ESU & $k$-USU\\
%		\hline
%		Monoidal & True for all $k$ & False for all $k > 0$\\
%		Nilpotent & NP-Hard & Polynomial time decidable\\
%		Combinational & True for all $k$ & Polynomial time decidable\\
%		Definite & Constant time decidable & Constant time decidable\\
%		Symmetric Definite & Constant time decidable & Constant time decidable\\
%		Suffix/Prefix Closed & NP-Hard & Polynomial time decidable\\
%		Ordered & NP-Hard & Polynomial time decidable\\
%		Commutative &  Polynomial time decidable &  False for all $k > 1$\\
%		Circular & NP-Hard &  Polynomial time decidable\\
%		Non-counting & Polynomial time decidable &  Polynomial time decidable\\
%		Star & Polynomial time decidable &  Polynomial time decidable\\
%		Left-sided comet & NP-Hard & Polynomial time decidable\\
%		Right-sided comet & NP-Hard & Polynomial time decidable\\
%		Two-sided comet & NP-Hard & Polynomial time decidable\\
%%		Contextual Grammars &  Polynomial time decidable & \\
%%		Internal Contextual Grammars & conjectured to be NP-hard
%	\end{tabular}
%\end{table}

%As far as the structure of the work is concerned, after introducing the key notations and definitions used through this work, in Section \ref{prelims}, we recall a series of graph theoretical insights related to automata, and give a series of algorithms that will be used as preprocessing in the main algorithmic results of the paper. Then we show our main results, and end the paper with some conclusions and ideas for future work.
%Due to space restrictions, some proofs are only given in Appendix~\ref{sec:appendixproofs}. 
Let  $\N = \{1,2,\ldots\}$ denote the natural numbers and set $\N_0 = \N
\cup \{0\}$. Let $[n]=\{1,\ldots,n\}$ and let $[i,n]=\{i, i+1, \ldots, n\}$ for all $i,n\in\N_0$ with $i \leq n$.

An \emph{alphabet} $\Sigma=\{1,2,\ldots,\sigma\}$ is a finite set of symbols, called
\emph{letters} (w.l.o.g., we can assume that the letters are integers). A \emph{word} (also known as a \emph{string}) $w$ is a finite sequence of letters from a given alphabet. The length of a word $w$, denoted $\vert w \vert$ is the number of letters in the word. For $i \in
[|w|]$ let $w[i]$ denote the $i^{th}$ letter of $w$.  The set of all
finite words over the alphabet $\Sigma$, denoted by $\Sigma^{\ast}$, is the free monoid generated by $\Sigma$ with
concatenation as operation and the neutral element is the empty word
$\varepsilon$, i.e., the word of length $0$. Given $n \in \N_0$, let $\Sigma^n$ denote all words in $\Sigma^{\ast}$ exactly of length $n$ and $\Sigma^{\leq n}$ the set of all words of $\Sigma^{\ast}$ of length at most $n$.
Let $\letters(w) = \{\ta \in \Sigma \mid \exists i \in [|w|]: w[i] = \ta \}$ be the alphabet of $w$. 
%and for each $\ta \in \Sigma$ set $|w|_{\ta} = |\{i \in [|w|] \mid w[i]=\ta \}|$.
For $u,w\in\Sigma^{\ast}$, $u$ is called a \emph{factor}
of $w$, if $w = xuy$ for some words $x,y\in\Sigma^{\ast}$. If $x = \varepsilon$ (resp.,
$y = \varepsilon$) then $u$ is called a \emph{prefix} (resp., \emph{suffix}) of
$w$.  For $1\leq i\leq j\leq|w|$ 
define the factor from $w$'s \nth{$i$} letter to the \nth{$j$} letter by  $w[i,j]=w[i]\cdots w[j]$.
Given a pair of indices $i  < j$, we assume $w[j, i] = \varepsilon$.
 For $w\in\Sigma^{\ast}$ and $n\in\N_0$ define inductively $w^0=\varepsilon$ and $w^n=ww^{n-1}$.
% Moreover, set $w^R=w[|w|]w[|w|-1]\cdots w[1]$ for $w\in\Sigma^{\ast}$.
%Let $<$ be an order relation on $\Sigma$ (e.g., the natural order on integers). We extend this order relation to the lexicographical order on $\Sigma^{\ast}$ in the following way: the word $u$ is lexicographically smaller than the word $w$ ($u<w$) iff either $u$ is a prefix of $w$ or there exists $x,y_1,y_2\in\Sigma^{\ast}$ and $\ta,\tb\in\Sigma$ with $u=x\ta y_1$, $w=x\tb y_2$ and $\ta<\tb$.\looseness=-1 % Do we use lexicographic ordering in this paper?


% \todofda{I think it would be useful to use some notation for $n$-length (or length at most $n$) words accepted by a given automaton $\mathcal{A}$, i.e. $\mathcal{A} \cap \Sigma^n$. I am not sure if there is a standard, but maybe something like $\mathcal{A}^n = \{w \in \Sigma^n \mid \delta(q_0, w) \in F \}$.
% Similarly, for words of length at most $n$, possible $\mathcal{A}^{\leq n}(w \in \Sigma^{*} \mid) \delta(q_0, w) \in F$ and $\mid w \mid \leq n$.}

% \begin{itemize}
% \item regular expression: each $\ta\in\Sigma$ is a regular expression, if $r_1,r_2$ are regular expressions then also $r_1|r_2,r_1r_2$, $(r_1)^{\ast}$
% \end{itemize}

As we are interested in investigating the $k$-subsequence universality of subregular languages, we first introduce the basic concepts related to subsequences. We then present the definitions for the transformation of these notions to the domain of subregular languages, finite automata and other language models.

\begin{definition}
	Let $w \in \Sigma^*$ and $n \in \N_0$. A word $u \in \Sigma^*$ is called \emph{subsequence} of $w$ ($u \in \Subseq(w)$) if there exist $v_1, \ldots, v_{n+1} \in \Sigma^*$ such that $w = v_1 u[1] v_2 u[2] \cdots v_n u[n] v_{n+1}$. Let $\Subseq_k(w) = \{u \in \Subseq(w) \mid \vert u \vert = k\}$.
	% Two words $w,v \in \Sigma^*$ are \emph{Simon congruent} w.r.t. $k\in\N_0$ ($w \sim_k v$) if $\Subseq_{\ell}(w) = \Subseq_{\ell}(v)$ for all $\ell\leq k$. Given $w\in\Sigma^{\ast}$, the word $u\in\Sigma^{\ast}$ is called {\em shortlex normal form} of $w$ w.r.t. $\sim_k$ if $u\sim_k w$ and $u$ is 
	% the lexicographically smallest word among the shortest words in $w$'s congruence class $[w]_{\sim_k}$.
\end{definition}

%\begin{example}
	Subsequences of $\mathtt{automatauniversality}$ are $\mathtt{auto}$, $\mathtt{tomata}$, $\mathtt{salty}$,  and $\mathtt{atom}$ while $\mathtt{star}$, $\mathtt{alien}$ are not because their letters occur in the wrong order.
%\end{example}

In \cite{barker2020scattered}, the authors investigated words which have, for a given $k\in\N_0$, all words from $\Sigma^{k}$ as subsequence, namely $k$-subsequence universal words. Note that this notion is similar to the one of richness introduced and investigated in \cite{KarandikarKS15,karandikar2016height}. We stick here to the notion of $k$-subsequence universality since our focus is subregular languages and thus the well-known notion of the universality of automata and formal languages, i.e., $L({A})=\Sigma^{\ast}$ for a given finite automaton ${A}$, is close to the one of subsequence universality of words.

\begin{definition}\label{def:subsequence}
	A word $w \in \Sigma^*$ is called \emph{$k$-subsequence universal} (w.r.t. $\Sigma$), for $k \in \N_0$, if	
	$\Subseq_k(w) = \Sigma^k$. If the context is clear we call $w$ $k$-universal. The universality-index $\iota(w)$  is the largest $k$ such that $w$ is $k$-universal.
\end{definition}

%We denote the set of $k$-universal words in a given set $\mathcal{M}\subseteq\Sigma^{\ast}$ by $\Univ_{\mathcal{M}, k}$. Thus, the set of all $k$-universal words over a given alphabet $\Sigma$ is denoted $\Univ_{\Sigma^*, k}$.
%\todo[inline]{I do not think that we use any of these notations, anywhere. They should be removed, as they are simply overloading the paper with notations.}

Further, we recall the {\em arch factorisation} by Hébrard \cite{hebrard1991algorithm}.

\begin{definition}
The {\em arch factorisation} of $w \in \Sigma^*$ is defined by $w = \ar_1(w) \cdots$ $\ar_k(w)$ $\r(w)$ for $k \in \mathbb{N}_0$ with
$\ar_i(w)[\vert \ar_i(w) \vert] \notin \letters(\ar_i(w)[1, \vert \ar_i(w) \vert - 1 ])$ for all $i \in [k]$ and $\iota(\ar_i(w))=1$, as well as $\letters(\r(w)) \subsetneq \Sigma$.
	The words $\ar_i(w)$ are the \emph{arches} and $\r(w)$ is the \emph{rest} of $w$.
% 	The modus of $w$ is the concatenation of the unique last letters of the arches, i.e., $\m(w)=\ar_1(w)[\vert\ar_1(w)\vert] \cdots\ar_k(w)[\vert\ar_k(w)\vert]$.
% 	The \emph{inner of the $i^{th}$ arch of $w$} is defined as the prefix of 
% 	$\ar_i(w)$ such that $\ar_i(w) = \inner_i(w) 
% 	\m(w)[i]$ holds.
\end{definition}


\begin{example}\label{prelims:exampleuniversalitycondt}
\label{prelims:exampleuniversality}
	Consider $w=\mathtt{baaababb} \in \{\ta,\tb\}^*$. We have $\vert \Subseq_3 (\mathtt{baaababb})\vert = \vert \{\mathtt{aaa}, \mathtt{aab}, \mathtt{aba}, \mathtt{abb}, \mathtt{baa}, \mathtt{bab}, \mathtt{bba}, \mathtt{bbb}\} \vert = 2^3$. Since $\mathtt{abba} \notin \Subseq_4(\mathtt{baaababb})$, it follows that $\iota(\mathtt{baaababb}) = 3$.
Further, $w=\mathtt{(ba) \cdot (aab) \cdot (ab) \cdot b}$ is the arch factorisation of $w$ where the parentheses denote the three arches and the rest $\mathtt{b}$.
% 	Further, $\m(\mathtt{baaababb}) = \mathtt{abb}$.
\end{example}
%{\color{orange}
%A proper subset of the $k$-universal words is given by all the words with an empty rest
%introduced in \cite{fleischmann2021scattered} as the set of {\em perfect $k$-universal} words. 
%
%\begin{definition}
%	We call a word $w \in \Sigma^*$ \emph{perfect $k$-universal} if $\iota(w)=k$ and $\r(w) = \varepsilon$. The set of all these words with $\letters(w)=\Sigma$ is denoted by $\PerfUniv_{\Sigma^\ast,k}$.
%\end{definition}
%
%\begin{example}
%	The word $\mathtt{baaababb}$ from Examples~\ref{prelims:exampleuniversality} and~\ref{prelims:exampleuniversalitycondt} is not perfect $3$-universal since it has $\iota(\mathtt{baaababb}) = 3$ but $\r(\mathtt{baaababb}) = \tb \neq \varepsilon$. To give a positive example, consider $\mathtt{abcbbaccbbaacb} \in \PUniv_{\{\ta,\tb,\tc\}^*,4}$ since its arch factorisation is  $\mathtt{(abc) \cdot (bbac) \cdot (cbba) \cdot (acb)}$.
%\end{example}}

% One frequently used result is the following which characterised the universality of words by their number of arches.

\begin{theorem}[\cite{barker2020scattered}]
	Let $w \in \Sigma^{\geq k}$ with $\al(w) = \Sigma$. Then we have $\iota(w)=k$ iff $w$ has exactly $k$ arches.
\end{theorem}


We now recall basic notions on finite automata, for further details we refer to \cite{HopcroftU79}. 
%
%
%
% \begin{definition}\label{def:finiteautomata}
A {\em non-deterministic finite automaton (NFA)} ${A}$ is a tuple $(Q,\Sigma,q_0,\delta,F)$ with the finite set of states $Q$ (of cardinality $n\in\N$), an initial state $q_0\in Q$, the set of final states $F\subseteq Q$, an input alphabet $\Sigma$, and a transition function $\delta:Q\times (\Sigma \cup \{\epsilon\}) \rightarrow 2^{Q}$, where $2^{Q}$ is the powerset of $Q$. If $q_2\in \delta(q_1,a)$, for some $a\in \Sigma \cup \{\epsilon\}$, then we have the transition $(q_1,a,q_2)$ in $A$. If we have $|\delta(q,a)|= 1$ and $\delta(q,\epsilon)= \emptyset$ for all $q\in Q, a\in \Sigma$, then ${A}$ is called {\em deterministic} (DFA). 

We call a sequence of transitions $\beta=(q,a_1,q_1)(q_1,a_2,q_2)\ldots(q_{\ell-1},a_{\ell},q_\ell)$ an \emph{$\ell$-length walk} from any $q \in Q$ to $q_\ell$ in ${A}$; in such a walk, we have $q_i\in Q$ for all $i\in[0,\ell]$, $a_i\in \Sigma\cup\{\epsilon\}$, and $q_{i+1}\in \delta(q_i,\ta_{i+1})$, for all $i\in[0,\ell-1]$.  The word $a_1\cdots a_\ell$ is the {\em label of $\beta$} and is denoted by $\labels(\beta)$. A state $q\in Q$ is called \emph{accessible} (respectively,\emph{co-accessible}) in ${A}$ if there exists a walk connecting $q_0$ to $q$ (respectively, $q$ to a final state). A walk is called {\em accepting} if $q_{\ell}\in F$ holds. The language of ${A}$, i.e., the set of words {\em accepted} by ${A}$, is $L({A})=\{w\in\Sigma^{\ast}\mid \exists \mbox{ accepting walk }\beta\mbox{ in }{A}:\,w=\labels(\beta)\}$. %For abbreviation, we set $\mathcal{A}_n=L(\mathcal{A})\cap\Sigma^n$ and $\mathcal{A}_{\leq n}=L(\mathcal{A})\cap\Sigma^{\leq n}$. 
Note that the class of languages accepted by NFAs is equal to the class of languages accepted by DFAs and it is equal to the class of regular languages. Moreover, for every word $w\in L({A})$ there exists exactly one (in the deterministic case) or a set (in the non-deterministic case) of walk(s) labelled with $w$. \looseness=-1
%For a word $w$ accepted by a finite automaton, let $\pi_w$ denote one accepting walk labelled with $w$; in the case when there are multiple such walks, we simply choose one of them. Since we usually are interested in only one walk for a word $w\in L(\mathcal{A})$, we refer to it as $\pi_w$.
 
%\begin{definition}\label{def:reverse_transition_function}
%	For a given NFA $\mathcal{A}$, the \emph{reverse transition function} $\Delta(q, \tx)$ returns the set of states in $Q$ with a transition labelled by $\tx$ to $q$, i.e, $\Delta(q, \tx) = \{q' \in Q \mid \delta(q', \tx) = q\}$.
%\end{definition}

% We now define regular expressions.
 Further, we define regular expressions (regex, for short) and their semantics.

\begin{definition}
	Let $\Sigma$ be an alphabet. Then $\emptyset, \varepsilon,$ and $\ta \in \Sigma$ are \emph{regular expressions}.
	Further, for two regular expressions $R_1$ and $R_2$, the terms $R_1 R_2$, $(R_1\mid R_2)$ and $(R_1)^*$ are regular expressions. 
	
	A regular expression $R$ that contains no $*$ is called \emph{star-free}.
%	\begin{enumerate}
%		\item $r_1 r_2$ is a regular expression, %with $\mathcal L(r_1 r_2) = \mathcal L(r_1) \mathcal L(r_2)$,
%		\item $r_1\mid r_2$ is a regular expression,% with $\mathcal L(r_1 \mid r_2) = \mathcal L(r_1)\cup \mathcal L(r_2)$, and
%		\item $r_1^*$ is a regular expression.% with $\mathcal L(r_1^*) = \mathcal L(r_1)^*$.
%	\end{enumerate}

	Let $R$ be a regular expression. Then the semantics of $R$ is inductively defined by the base cases $L (\emptyset) = \emptyset$, $L(\varepsilon) = \{\varepsilon\}$ and ${L}(\ta) = \{\ta\}$ for $\ta\in\Sigma$.
	Further, we define $ L(R_1 R_2) =  L(R_1)  L(R_2)$, $ L((R_1 | R_2)) =  L(R_1)\cup  L(R_2)$ and $ L((R_1)^*) =  L(R_1)^*$ for regular expressions $R_1,R_2$.
	
	$ L(R)$ is called the language described by the regular expression $R$. 
\end{definition}

 For example, $ L (\ta^*\tb|\varepsilon) =  L (\ta^* \tb) \cup \{\varepsilon\} =  L (\ta^*) \{\tb\} \cup \{\varepsilon\} = \{\ta\}^* \{\tb\} \cup \{\varepsilon\}$.

Now, we can define the $k$-subsequence universality of a regular language~$L$. Here, we distinguish whether at least one or all words of $L$ are $k$-universal w.r.t.~Definition~\ref{def:subsequence}. Note that we always take the minimal alphabet $\Sigma$ such that $L\subseteq \Sigma^*$ as a reference when considering the $k$-universality of words from $L$, as otherwise, for larger alphabets, the universality is trivially $0$.

\begin{definition}\label{def:univ} Let $k\in \N$ be an integer.
A language $L$ is {\em existence $k$-subsequence universal} ($k$-$\exists$-universal) if there
exists a $k$-universal word $w\in L$, and $L$ is {\em universal $k$-subsequence universal} ($k$-$\forall$-universal) if all words $w\in L$ are $k$-universal. \looseness=-1
\end{definition}

If a language $L$, accepted (represented) by some automaton ${A}$ (or regular expression $R$), is $k$-$\exists$-universal (respectively, $k$-$\forall$-universal) then we also say that the automaton ${A}$ (regular expression $R$) is $k$-$\exists$-universal (respectively, $k$-$\forall$-universal). We also say that a {\em walk $\pi$ in ${A}$ is $k$-universal} if $\labels(\pi)$ is $k$-universal. 
%As an example, a $2$-$\exists$-universal NFA ${A}$, which is not $3$-$\exists$-universal, and a $1$-$\forall$-universal NFA ${B}$ which is not $2$-$\forall$-universal are shown in Figure~\ref{img:universal_automaton}\ifpaper, Appendix~\ref{sec:furtherdefs} \else\fi (note that $ B$ recognises exactly every permutation of $\ta\tb\tc$). Further

For instance, the expression $(\ta^*\tb^*\tc | \tb\tc) | \ta^*$ is a $1$-$\exists$-universal regular expression that is not $2$-$\exists$-universal. Further examples are given in Figure~\ref{img:universal_automaton}. 

Starting from Definition \ref{def:univ}, two decision problems were introduced in \cite{regunivpaper}. 

\ifpaper
\else
\input{figure}
\fi


%\begin{problem}\label{prob:esubfa}
\begin{itemize}[leftmargin=10pt,itemsep=1cm,parsep=-1cm]
\item[1.] The {\em existence subsequence universality problem for regular languages ($k$-ESU)} is to decide for a language, given by an NFA $\mathcal{A}$ recognising it (respectively, by a regex $R$ describing it), and $k\in\N$ whether $L$ is $k$-$\exists$-universal. 
%\end{problem}

%Note that the following problem was called $k$-ASU in a former version.
%\begin{problem}\label{prob:asubfa}
\item[2.] The {\em universal subsequence universality problem for regular languages ($k$-USU)} is to decide for a language, given by an NFA $\mathcal{A}$ recognising it (regex $R$ describing it), and $k\in\N$ whether $L$ is $k$-$\forall$-universal.
		\vspace*{-5pt}
\end{itemize}
%\end{problem}

Here we focus on the first problem, as $k$-USU can already be solved in polynomial time for all regular languages, given as NFAs or regexes. 

%\todoah{@Duncan I don't think we need this?}
%\todofda{I agree}
%We finish this section by introducing the {\em rank} of a word in order to enumerate the $k$-universal words accepted by a given finite automaton.
%
%% \todofpa{the rank is independent of the length, cf Signal}
%\begin{definition}
%	\label{def:rank}
%	The \emph{rank} of a word $w$ within the set $\Univ_{\mathcal{M}, k}$ is the number of words in $\Univ_{\mathcal{M}, k}$ lexicographically smaller than $w$, i.e. $rank(w) = \lvert \{ v \in \Univ_{\mathcal{M}, k} \mid v < w\}\rvert$.
%\end{definition}


%\begin{remark}
%	By Definition~\ref{def:subsequence}, % and \ref{def:finiteautomata} 
%	the set of all $k$-universal words accepted by $\mathcal{A}$ is given by $\Univ_{L(\mathcal{A}), k}$, the set of all $n$-length  $k$-universal words accepted by $\mathcal{A}$ is given by  $\Univ_{\mathcal{A}_n, k}$, and the set of all $k$-universal words of length at most $n$ accepted by $\mathcal{A}$ is given by $\Univ_{\mathcal{A}_{\leq n}, k}$.
%\end{remark}

%\paragraph*{Subregular Languages}

%We consider the following restrictions for regular languages. Let $L \subseteq \Sigma^*$ be a language. 
%With respect to the alphabet $\Sigma$, the language $L$ is:
%\ifpaper
%\begin{itemize}
%	\item \emph{monoidal} ($\MON$) iff $L=\Sigma^*$,
%	\item \emph{nilpotent} $(\NIL$) iff it is finite or its complement $\Sigma^*\setminus L$ is finite,
%	\item \emph{combinational} ($\COMB$) iff $L=\Sigma^*X$
%	for some subset $X\subseteq \Sigma$,
%	\item \emph{symmetric definite} ($\SYDEF$) iff $L = E\Sigma^* H$ for regular languages $E,H$,
%	\item \emph{suffix-closed} ($\SUF$) (or \emph{fully initial} or \emph{multiple-entry} language) iff, for any two words~$x\in \Sigma^*$ and~$y\in \Sigma^*$, the relation $xy\in L$ implies
%	the relation~$y\in L$,
%	\item \emph{ordered} ($\ORD$) iff the language is accepted by some deterministic finite
%	automaton 
%	${\cal A}=(\Sigma,Z,z_0,F,\delta)$
%	with an input alphabet $\Sigma$, a finite set $Z$ of states, a start state $z_0\in Z$, a set $F\subseteq Z$ of
%	accepting states and a transition mapping $\delta$ where $(Z,\preceq )$ is a totally ordered set and, for
%	any input symbol~$a\in \Sigma$, the relation $z\preceq z'$ implies $\delta (z,a)\preceq \delta (z',a)$,
%	\item \emph{commutative} ($\COMM$) iff it contains with each word also all permutations of this
%	word,
%	\item \emph{circular} ($\CIRC$) iff it contains with each word also all circular shifts of this
%	word,
%	%\item \emph{quasi-power-separating} if and only if, for any $x\in \Sigma^*$, there is a natural number
%	%$m\geq 1$ such that either $J_x^m \cap L = \emptyset$
%	%or $J_x^m\subseteq L$ where $J_x^m = \{ x^n\mid n\geq m\}$,
%	%\item \emph{strictly locally $k$-testable} if and only if there are three subsets $B$, $I$, and $E$ of $V^k$
%	%such that any word $a_1a_2\ldots a_n$ with $n\geq k$ and $a_i\in V$ for $1\leq i\leq n$ belongs to the language $L$
%	%if and only if~$a_1a_2\ldots a_k\in B$, $a_{j+1}a_{j+2}\ldots a_{j+k}\in I$ for $1\leq j\leq n-k-1$,
%	%and $a_{n-k+1}a_{n-k+2}\ldots a_n\in E$,
%	%\item \emph{strictly locally testable} if and only if it is strictly locally $k$-testable for some natural number $k$.
%	\item \emph{star} ($\STAR$) iff $L = H^*$ for some regular language $H \subseteq \Sigma^*$,
%	\item \emph{left-sided comet} ($\LCOM$) iff $L = EG^*$ for some regular languages $E$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$,
%	\item \emph{right-sided comet} ($\RCOM$) iff $L = G^*H$ for some regular languages $H$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$.
%\end{itemize}
%Further subregular languages for which we get immediate results by taking inclusion relations as shown in Figure~\ref{fig:hierarchy} into account can be found in Appendix~\ref{sec:furtherdefs}.
%\else
%\begin{itemize}
%	\item \emph{monoidal} ($\MON$) iff $L=\Sigma^*$,
%	\item \emph{nilpotent} $(\NIL$) iff it is finite or its complement $\Sigma^*\setminus L$ is finite,
%	\item \emph{combinational} ($\COMB$) iff $L=\Sigma^*X$
%	for some subset $X\subseteq \Sigma$,
%	\item \emph{definite} ($\DEF$) iff $L=A\cup \Sigma^*B$
%	where~$A$ and~$B$ are finite subsets of $\Sigma^*$,
%	\item \emph{symmetric definite} ($\SYDEF$) iff $L = E\Sigma^* H$ for regular languages $E,H$,
%	\item \emph{suffix-closed} ($\SUF$) (or \emph{fully initial} or \emph{multiple-entry} language) iff, for any two words~$x\in \Sigma^*$ and~$y\in \Sigma^*$, the relation $xy\in L$ implies
%	the relation~$y\in L$,
%	\item \emph{ordered} ($\ORD$) iff the language is accepted by some deterministic finite
%	automaton 
%	${\cal A}=(\Sigma,Z,z_0,F,\delta)$
%	with an input alphabet $\Sigma$, a finite set $Z$ of states, a start state $z_0\in Z$, a set $F\subseteq Z$ of
%	accepting states and a transition mapping $\delta$ where $(Z,\preceq )$ is a totally ordered set and, for
%	any input symbol~$a\in \Sigma$, the relation $z\preceq z'$ implies $\delta (z,a)\preceq \delta (z',a)$,
%	\item \emph{commutative} ($\COMM$) iff it contains with each word also all permutations of this
%	word,
%	\item \emph{circular} ($\CIRC$) iff it contains with each word also all circular shifts of this
%	word,
%	\item \emph{non-counting} ($\NC$) iff there is a natural
%	number $k\geq 1$ such that, for any three words $x\in \Sigma^*$, $y\in \Sigma^*$, and $z\in \Sigma^*$, it 
%	holds~$xy^kz\in L$ if and only if $xy^{k+1}z\in L$,
%	\item \emph{star-free} ($\SF$) iff $L$ can be described by a regular expression which is built by concatenation, union, and complementation,
%	%\item \emph{quasi-power-separating} if and only if, for any $x\in \Sigma^*$, there is a natural number
%	%$m\geq 1$ such that either $J_x^m \cap L = \emptyset$
%	%or $J_x^m\subseteq L$ where $J_x^m = \{ x^n\mid n\geq m\}$,
%	\item \emph{power-separating ($\PS$)} iff, there is a natural number $m\geq 1$ such that
%	for any word~$x\in \Sigma^*$, either
%	$J_x^m \cap L = \emptyset$
%	or
%	$J_x^m\subseteq L$
%	where
%	$J_x^m = \{ x^n \mid n\geq m\}$,
%	\item \emph{union-free} ($\UF$) iff $L$ can be described by a regular expression which
%	is only built by product and star,
%	%\item \emph{strictly locally $k$-testable} if and only if there are three subsets $B$, $I$, and $E$ of $V^k$
%	%such that any word $a_1a_2\ldots a_n$ with $n\geq k$ and $a_i\in V$ for $1\leq i\leq n$ belongs to the language $L$
%	%if and only if~$a_1a_2\ldots a_k\in B$, $a_{j+1}a_{j+2}\ldots a_{j+k}\in I$ for $1\leq j\leq n-k-1$,
%	%and $a_{n-k+1}a_{n-k+2}\ldots a_n\in E$,
%	%\item \emph{strictly locally testable} if and only if it is strictly locally $k$-testable for some natural number $k$.
%	\item \emph{star} ($\STAR$) iff $L = H^*$ for some regular language $H \subseteq \Sigma^*$,
%	\item \emph{left-sided comet} ($\LCOM$) iff $L = EG^*$ for some regular languages $E$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$,
%	\item \emph{right-sided comet} ($\RCOM$) iff $L = G^*H$ for some regular languages $H$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$,
%	\item \emph{two-sided comet} ($\TCOM$) iff $L = EG^*H$ for some regular languages $E,H$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$.
%\end{itemize}
%\fi
%
%Further, we define subregular languages by restricted sets of states and grammar restrictions:
%\begin{align*}
%	REG_n^Q =& \{L \mid L \text{ is accepted by a DFA with at most $n$ states}\},\\
%	RL_n^\Sigma =& \{L \mid L \text{ is generated by a right-linear grammar}\\ 
%	&\text{with at most $n$ non-terminal symbols}\},\\
%	RL_n^P =& \{L \mid \text{ is generated by a right-linear grammar}\\
%	&\text{with at most $n$ production rules}\}.
%\end{align*}
%
%A visualisation of the inclusion properties of the presented subregular languages can be found in \cite{DBLP:journals/corr/abs-2409-06974} and \cite{DBLP:journals/corr/abs-2309-08724} (cf. Figure~\ref{fig:hierarchy}).

\ifpaper
Our computational model is the RAM model with word size $\omega \geq \log n $, where $n$ is the size of the input; that is, the input size never exceeds $2^\omega$. We also assume that the given strings are over integer alphabets $\Sigma=\{1,\ldots,\sigma\}$, while input NFAs have state-sets $Q=\{0,\ldots,q\}$, with $
\sigma,q\leq n$. See Appendix~\ref{sec:computational_model} for details.\looseness=-1
\else
\subsubsection*{Computational Model}
\input{compmodel}
\fi





\begin{figure}
	\centering
	\begin{minipage}[c]{0.3\textwidth}
		\scalebox{0.7}
		{\begin{tikzpicture}
				[->,>=stealth',shorten >=1pt,auto,node distance=1.6cm,semithick]
				\tikzstyle{every state}=[initial text=$ $]
				\node[initial,state] (A)                    {$q_0$};
				\node[state]         (B) [right of=A]       {$q_1$};
				\node[state,accepting] (D) [right of=B]     {$q_2$};
				
				\path (A) edge [loop above] node {$\mathtt{a}, \mathtt{b}$} (A)
				edge              node {$\mathtt{c}$} (B)
				%		(B) edge [loop above] node {$\mathtt{b}, \mathtt{c}$} (B)
				(B) edge              node {$\mathtt{a}$} (D)
				(D) edge [loop above] node {$\mathtt{b,c}$} (D);
				\node at (-1,1) {${A}$};
		\end{tikzpicture}}
	\end{minipage}	
	\begin{minipage}[c]{0.4\textwidth}
		\scalebox{0.7}
		{\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=1.6cm,
				semithick]
				\tikzstyle{every state}=[initial text=$ $]
				\node[initial,state] (A)                    {$q_0$};
				\node[state]         (B) [below left of=A]       {$q_1$};
				\node[state]         (C) [below left of=B]       {$q_2$};
				\node[state,accepting] (D) [below of=C]       {$q_3$};
				\node[state]         (E) [below of=B]       {$q_4$};
				\node[state,accepting] (F) [below of=E]       {$q_5$};
				\node[state]         (q6) [below of=A]        {$q_6$};
				\node[state]         (q7) [below of=q6]       {$q_7$};
				\node[state,accepting] (q8) [below of=q7]       {$q_8$};
				\node[state]         (q9) [below right of=q6]       {$q_9$};
				\node[state,accepting] (q10) [below of=q9]       {$q_{10}$};
				\node[state]         (q11) [above right of=q9]       {$q_{11}$};
				\node[state]         (q12) [below of=q11]       {$q_{12}$};
				\node[state,accepting] (q13) [below of=q12]       {$q_{13}$};
				\node[state]         (q14) [below right of=q11]       {$q_{14}$};
				\node[state,accepting] (q15) [below of=q14]       {$q_{15}$};
				
				\path (A) edge node {$\mathtt{a}$} (B)
				edge node {$\mathtt{b}$} (q6)
				edge node {$\mathtt{c}$} (q11)
				(B)	edge node {$\mathtt{b}$} (C)
				edge node {$\mathtt{c}$} (E)
				(C) edge node {$\mathtt{c}$} (D)
				(E) edge node {$\mathtt{b}$} (F)
				(q6) edge node {$\mathtt{a}$} (q7)
				edge node {$\mathtt{c}$} (q9) 
				(q7) edge node {$\mathtt{c}$} (q8)
				(q9) edge node {$\mathtt{a}$} (q10)
				(q11) edge node {$\mathtt{a}$} (q12)
				edge node {$\mathtt{b}$} (q14)
				(q12) edge node {$\mathtt{b}$} (q13)
				(q14) edge node {$\mathtt{a}$} (q15);
				\node at (-3,0) {${B}$};
		\end{tikzpicture}}
	\end{minipage}
	\caption{A $2$-$\exists$-universal NFA ${A}$ and a $1$-$\forall$-universal  NFA ${B}$. In ${A}$, we have the 2 universal word $\mathtt{a}\mathtt{b}\mathtt{c}\mathtt{a}\mathtt{b}\mathtt{c}$, however no word can contain more than $1$ occurrence of $\mathtt{a}$ after the first occurrence of $\mathtt{c}$, thus can contain at most $2$-arches. In ${B}$, we have a regular language that recognises the set of permutations of $\mathtt{a} \mathtt{b} \mathtt{c}$, thus each word contains exactly one arch and hence is $1$-universal.}
	\label{img:universal_automaton}
\end{figure}
%\subsubsection*{Computational Model}
The computational model we use to state our algorithms is the standard unit-cost word RAM with logarithmic word-size $\omega$ (meaning that each memory word can hold $\omega$ bits). It is assumed that this model allows processing inputs of size $n$, where $\omega \geq \log n$; in other words, the size $n$ of the data never exceeds (but, in the worst case, is equal to) $2^\omega$. Intuitively, the size of the memory word is determined by the processor, and larger inputs require a stronger processor (which can, of course, deal with much smaller inputs as well). Indirect addressing and basic arithmetical operations on such memory words are assumed to work in constant time. Note that numbers with $\ell$ bits are represented in $\O(\ell/\omega )$ memory words, and working with them takes time proportional to the number of memory words on which they are represented. This is a standard computational model for the analysis of algorithms, defined in \cite{FredmanW90}. Our algorithms have automata, strings (regular expressions), and numbers as input, so we follow standard assumptions, Namely, we work with languages over {\em integer alphabets} (see, e.\,g.,~\cite{crochemore}): whenever we are given an input of size $n$, we assume that the alphabet of the given automata or regex is $\Sigma=\{1,2,\ldots,\sigma\}$, with $|\Sigma|=\sigma\leq n$; we also assume that the states of the input automata, when we deal with this model, are given as integers from $\{1,\ldots,q\}$, where $q\leq n$. Also, automata are specified as a list of states (with the initial state and the final ones highlighted), and, for each state we are given the list of transitions leaving it. 

One of our algorithms (from Theorem \ref{thm:FPT_sigma}, which is then used as a subroutine in Theorem \ref{thm:FPT_sigma_regex}, as well) uses exponential space w.r.t.\ the size of the input alphabet, namely $\sigma$, but polynomial w.r.t.\ all the other components of the input. To avoid clutter, we assume that our exponential-time and -space algorithms runs on a RAM model where we can allocate as much memory as our algorithms needs (i.e., the size of the memory-word $\omega$ is big enough to allow addressing all the memory we need in this algorithm in constant time). For the case of $\sigma \in O(1)$, this additional assumption becomes superfluous; for non-constant $\sigma$, we emphasise that the big size of memory words is only used for building and addressing large data structures (that is, large matrices), but not for speeding up our algorithms by, e.g., allowing constant-time operations on big numbers (that is, numbers exponential in the size of the input).

% Some of our algorithms run in exponential time and use exponential space w.r.t. the size $n$ of the input. Following the literature dealing with such exponential algorithms (see, e.g., \cite{FominKTV08}), we will use the $O^*$-notation. By definition, for functions $f$ and $g$ we write $f(n) = O^*(g(n))$ if $ f(n)=O(g(n)n^{O(1)})$. In other words, the $O^*$-notation hides polynomial factors, just as the $O$-notation hides constants. Using this notation, we can assume that our single-exponential time and single-exponential space algorithms run on a RAM model where arithmetic and bitwise operations with single exponential numbers (w.r.t. the size $n$ of the input) as well as accessing the memory-words (given their address, like in an usual RAM) are assumed to take $O^*(1)$ time. Working with such a computational model allows us to analyse the actual algorithms rather than the various intricacies of the computational model.

% In particular, when expressing the complexity of our algorithms, we get functions which are exponential in $\sigma$ (the size of the alphabet) but polynomial in the number $n$ of states of the input NFA or, for the enumeration algorithms, in the length $m$ of the enumerated strings or in the value of the input number $k$ (the parameter of the considered problems). For clarity of the exposure, although we use the $O^*$-notation, we will explicitly write the dependency on $n, m,$ and $k$, and only hide the polynomial dependency on $\sigma$. 
%\fi
%
% \begin{remark}\label{rem:combinatorial_2}
%	We can determine if a combinatorial language $L$ is $k$-USU for any $k \in \N$ and non-empty $X$ in time equal to the complexity of deciding if $X$ is $k$-USU.
%  \end{remark}
%
%We note that the complexity given in Remark \ref{rem:combinatorial_2} gives, in the general case, an NP-hardness result. However, if $X$ is instead a subregular language, the complexity will then match that of the corresponding language.
%\todoah{$\uparrow$ I think since $X \subseteq \Sigma$ (not $\Sigma^*$) this problem is not NP-hard in any case}
%
%
%\begin{proposition}
%	We can determine if the ordered language $L$ given by an $n$-state DFA $\mathcal{A}$ is $k$-ESU, for every $k \in \mathbb{N}$ in $O(\sigma n)$ time.
%\end{proposition}
%\begin{proof}
%	Observe that $L$ is $k$-ESU if and only if there exists at least one accepting state with a self-loop labelled by each of the symbols in $\Sigma$. As we can determine if such a state exists by examination of the transition table, we can solve this problem in $O(\sigma n)$ time.
%%
%	% Now, let us assume that no such state exists. Then, to determine the maximum value $k$ such that there exists at least one word with a universality of $k$, we observe that 
%%
%%	First, observe that the maximium number of transitions in $\mathcal{A}$ is $\sigma n$. 
%%	We note that 
%%
%%	Let $n = \mathcal A$. The maximal number of transitions in $\mathcal A$ is $\sigma \sum_{i=i}^{n-1}i$. Using BFS we can find all walks from an initial to a final state in runtime $O(n + \sigma \sum_{i=i}^{n-1}i)$ while computing the arch factorisation of each walk in linear time in the walk length. Check whether one of the final states has a self-transition with $\Sigma$ if not then answer the $k$-ESU problem negatively. Otherwise, let $F_\circ$ be this set of final states that have a self-transition with $\Sigma$ and $\ell$ be the smallest universality index amongst all walks ending in $F_\circ$. %The $k$-ESU problem can be answered positively for all $k \geq \ell$, and the $k$-USU problem can be answered positively iff $\ell =0$.
%\end{proof}
%
%\begin{proposition}
%	For ordered languages $L$ given by an $n$-state DFA $\mathcal{A}$ and $k \in \N$, the $k$-ESU problem %and $k$-USU 
%	for finite values of $k$ is NP-complete even when $k = 1$.
%\end{proposition}
%
%\begin{proof}
%	We note the the reduction in \cite{regunivpaper} uses an ordered DFA to show that $k$-ESU is NP-hard in general, giving the statement.
%\end{proof}

%\begin{proposition}
%	\label{prop:commutative_finite_k}
%	For a $k \in \N$ and a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, the $k$-ESU problem can be decided in $O(\sigma k + n\sigma)$ time.
%\end{proposition}
%\begin{proof}
%	Let $\mathcal A = (Q,\Sigma, \delta, q_0, F)$ with $|Q| = n$ and $L(\mathcal A) = L$.  Now, let $q$ be the state reached by following the walk $\pi_{w}$ for $w = \ta^k \tb^k \cdots \sigma^k$. Note that, as $\mathcal{A}$ is commutative, if there exists any word containing $k$ arches, there must also exist some word with the prefix $w$. Therefore, if $q$ is either an accepting state, or can reach an accepting state by some set of transitions, there exists some set of $k$-subsequence universal words in $L$. Otherwise, no such word exists. As we can determine if any such walk exists in $O(n \sigma)$ time via a depth-first search, we obtain the complexity.
%%
%% Check whether the walk $a^k b^k \cdots \sigma^k$ ends in an accepting state or a state that can reach an accepting state by following.
%% one transition apart from an accepting state. Since the automaton is a DFA, there is a unique walk for $a^k b^k \cdots \sigma^k$. Thus, we can verify this in $O(\sigma k)$.
%\end{proof}
%
%\begin{proposition}
%	\label{prop:commutative_infinite_k}
%	For a $k \in \N$ and a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, we can determine if there is a positive solution to the $k$-ESU problem for every $k \in \mathbb{N}$ in $O(n \sigma)$ time.
%\end{proposition}
%
%\begin{proof}
%	Consider the word $w = \ta^{n + 1} \tb^{n + 1} \dots \sigma^{n + 1}$. Observe that if there exists some $v\in \Sigma^*$ such that $w v \in L$, then the walk induced by $w$ must include at least one cycle labelled by each symbol in $\Sigma$. Let $\ell_{i}$ be the length of the cycle in $\mathcal A$ taken by the walk induced by $w$ labelled by the symbol $i \in \Sigma$. Then, as  $w v \in L$, we have that $ \ta^{n + 1 + c \cdot \ell_\ta} \tb^{n + 1 + c \cdot \ell_\tb} \cdots \sigma^{n + 1 + c \cdot \ell_{\sigma}} v \in L$, for all $c \in \mathbb{N}$.
%	In the other direction, of $L$ is not $(n + 1)$-ESU, then $L$ can not be $k$-ESU for any $k \geq n + 1$.
%Therefore, we can determine the statement in $O(n \sigma)$ time by checking if $L$ is $(n + 1)$-ESU, requiring, by Proposition \ref{prop:commutative_finite_k}, $O(n \sigma)$ time.
%\end{proof}
%
%\begin{proposition}
%	For a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, we can find the maximal $k$ such that $k$-ESU is fulfilled in $O(n \sigma \log n)$ time.
%\end{proposition}
%\begin{proof}
%	We do this by way of a binary search on the values of $k$. Starting with $k = n + 1$, we determine if the value of $k$ is finite via Proposition \ref{prop:commutative_infinite_k} in $O(n \sigma)$ time.
%	If $k$ is finite, then we may perform a binary search over the possible values of $k$, starting with $k = n / 2$, and precoding accordingly. As each $k$ requires $O(n \sigma)$ time to process, and we require at most $\log n$ such checks, the total time complexity of this process is $O(n \sigma \log n)$.
%%	Let $\mathcal A = (Q,\Sigma, \delta, q_0, F)$ with $|Q| = n$ and $L(\mathcal A) = L$. By definition, we know that for an arbitrary $k\in \N$ the strictly $k$-universal word $w$
%%%	with $y \in \Sigma^*$ with $\al(y) \subset \Sigma$ 
%%	is contained in the language iff its sorted permutation $\ta^{\ell_\ta} \tb^{\ell_\tb} \cdots \sigma^{\ell_\sigma}$ is contained for $\ell_i \in \N_{\geq k}$, $i \in [\sigma]$. Thus, we need to find the largest possible powers $\ell_i$ such that $\ta^{\ell_\ta} \tb^{\ell_\tb} \cdots \sigma^{\ell_\sigma}$ is accepted by the automaton. Then the smallest amongst the $\ell_i$ is the largest universality we can reach (the permutation we construct does contain this letter that occurs the fewest as the modus). In order to find the largest possible values for $\ell_i$ we go from the initial state and use the Floyd-Warshall algorithm to compute all pairs of shortest walks between the initial and final states that are of the form $\ta^{\ell_\ta} \tb^{\ell_\tb} \cdots \sigma^{\ell_\sigma}$ (all other pairs are omitted) in $O(n^3)$ time while storing the number of letters $\ell_i$ along the walk and possible single letter loops within a block of $\ta^{\ell_\ta} \tb^{\ell_\tb} \cdots \sigma^{\ell_\sigma}$. If every block $\mathtt{i}^{\ell_i}$, $\mathtt{i} \in \Sigma$ contains a loop, there exist $k$-universal words  for every $k\in \N$. If there exists a letter $\mathtt{i} \in \Sigma$ without a loop in its block then we compute the maximal power for each of those letters by counting the number of transitions from the beginning to the end of their block. Let $\ell_j$ for $j \in [\sigma]$ be the smallest value amongst all exponents. Thus, we can conclude that the universality of the language is bounded by $\ell_j$ since $k$ was chosen arbitrarily.
%\end{proof}
%    
%  
%\begin{lemma}
%	For $k \in \N$ and union-free subregular languages given by their regular expression $R$ we can decide $k$-ESU and $k$-USU in $O(|R|)$ time. 
%\todoah{if we solved it use star-free: find outermost star and apply star-free on inner part}
%\end{lemma}
%\begin{proof}
%	Perform a left to right scan through the regular expression and determine the outermost starred expression. During this procedure track whether $\Sigma$ is contained completely in the outermost starred expression. If so, the $k$-ESU can be answered positively for all $k\in \N$. 
%\end{proof}
%\subsection{New Attempt on organising this section}
%As shown in \cite{regunivpaper} the $k$-ESU problem is NP-hard for regular languages represented by automata. In this section, we are going to investigate subsets of regular languages and discuss their complexity of $k$-ESU.
%The inclusion hierarchy of subregular languages is shown in Figure~\ref{fig:hierarchy}. An edge visualises a proper inclusion of the subregular language from its origin in its goal together with the according reference. Further, unconnected nodes are incomparable. 
%
%\begin{figure}[htb]
%	\centering
%	\scalebox{0.7}{
%		\begin{tikzpicture}[node distance=15mm and 16mm, on grid]
%			\node (MON) {$REG_1^Q$};
%			\node (MON2) [below =of MON] {$\MON$};
%			\node (d0)[above=of MON] {};
%			\node (FIN)[right=of d0] {$\FIN$};
%			\node (NIL)[above=of d0] {$\NIL$};
%			\node (COMB)[left=of NIL] {$\COMB$};
%			\node (DEF)[above=of NIL] {$\DEF$};
%			\node (d1)[left=of DEF] {};
%			\node (SYDEF)[left=of d1] {$\SYDEF$};
%			\node (d2)[right=of DEF] {};
%			\node (d3)[right=of d2] {};
%			\node (SUF)[right=of d3] {$\SUF$};
%			\node (ORD)[above=of DEF] {$\ORD$};
%			\node (NC)[above=of ORD] {$\NC\stackrel{\text{\cite{mcnaughton1971counter}}}{=}\SF$};
%			\node (PS)[above=of NC] {$\PS$};
%			\node (RCOM)[above=of SYDEF] {$\RCOM$};
%			\node (LCOM)[left=of RCOM] {$\LCOM$};
%			\node (TCOM)[above=of RCOM] {$\TCOM$};
%			\node (UF)[left=of LCOM] {$\UF$};
%			\node (STAR)[below=of UF] {$\STAR$};
%			\node (REG) [above of = PS] {$\REG$};
%			\node (COMM)[left=of STAR] {$\COMM$};
%			\node (CIRC)[above=of COMM] {$\CIRC$};
%			
%			\node (RLV1) [right of= DEF] {$RL_1^\Sigma$};
%			\node (RLV2) [above of= RLV1] {$RL_2^\Sigma$};
%			\node (moreRLV) [above of= RLV2] {$\vdots$};
%			
%			\node (REGQ2) [right of= RLV1] {$REG_2^Q$};
%			\node (moreREGQ) [above of= REGQ2] {$\vdots$};
%			
%			
%			\node (RLP4) [right=of SUF] {$RL_4^P$};
%			\node (moreRLP) [above of= RLP4] {$\vdots$};
%			\node (RLP3) [below=of RLP4] {$RL_3^P$};
%			\node (RLP2) [below=of RLP3] {$RL_2^P$};
%			\node (RLP1) [below right=of FIN] {$RL_1^P$};
%			
%			
%			
%			\draw[->, >=angle 60] (MON2) to node {} (MON);
%			\draw[->, >=angle 60,bend left] (MON) to node[edgeLabel] {\small\cite{DBLP:journals/corr/abs-2409-06974}} (STAR);
%			\draw[->, >=angle 60,bend left] (MON) to node[edgeLabel] {\small\cite{DBLP:journals/corr/abs-2409-06974}} (SYDEF);
%			\draw[->, >=angle 60] (RCOM) to node[pos=.45,edgeLabel]{\small\cite{DBLP:journals/tcs/BordihnHK09}}(TCOM);
%			\draw[->, >=angle 60] (LCOM) to node[edgeLabel]{\small\cite{DBLP:journals/corr/abs-2409-06974}}(TCOM);
%			\draw[bend left=20] (TCOM) to node[edgeLabel]{\small\cite{DBLP:journals/tcs/BordihnHK09}}(REG);
%			\draw[->, >=angle 60] (STAR) to node[pos=.45,edgeLabel]{\small\cite{DBLP:journals/corr/abs-2409-06974}} (UF);
%			\draw[->, >=angle 60,bend left] (UF) to node[edgeLabel]{\small\cite{DBLP:conf/ncma/HolzerT15}}(REG);
%			\draw[->, >=angle 60,bend left] (MON) to node[pos=.7,edgeLabel]{\small\cite{truthe2018hierarchy}} (COMM);
%			\draw[->, >=angle 60] (COMM) to node[pos=.45,edgeLabel]{\small\cite{DBLP:conf/ncma/HolzerT15}}(CIRC);
%			\draw[->, >=angle 60,bend left] (CIRC) to node[edgeLabel]{\small{\cite{DBLP:conf/ncma/HolzerT15}}}(REG);
%			\draw[->, >=angle 60] (MON) to node[pos=.45,edgeLabel]{\small\cite{truthe2018hierarchy}} (NIL);
%			\draw[->, >=angle 60] (NIL) to node[pos=.45,edgeLabel]{\small\cite{wiedemann1978vergleich}}(DEF);
%			\draw[->, >=angle 60] (DEF) to node[pos=.45,edgeLabel]{\small\cite{DBLP:conf/ncma/HolzerT15}}(ORD);
%			\draw[->, >=angle 60] (ORD) to node[pos=.45,edgeLabel]{\small\cite{shyr1974ordered}}(NC);
%			\draw[->, >=angle 60] (NC) to node[pos=.4,edgeLabel]{\small\cite{DBLP:journals/mst/ShyrT74}}(PS);
%			\draw[->, >=angle 60] (PS) to node[pos=.45,edgeLabel]{\small\cite{DBLP:conf/ncma/HolzerT15}}(REG);
%			\draw[->, >=angle 60,bend right] (MON) to node[pos=.7,edgeLabel]{\small\cite{truthe2018hierarchy}}(SUF);
%			\draw[->, >=angle 60,bend right] (SUF) to node[edgeLabel]{\small\cite{DBLP:conf/ncma/HolzerT15}}(PS);
%			\draw[->, >=angle 60] (FIN) to node[pos=.45,edgeLabel]{\small\cite{wiedemann1978vergleich}}(NIL);
%			\draw[->, >=angle 60] (COMB) to node[pos=.45,edgeLabel]{\small\cite{havel1969theory}}(DEF);
%			\draw[->, >=angle 60] (COMB) to node[pos=.45,edgeLabel]{\small\cite{Olejar_Szabari.2023}}(SYDEF);
%			\draw[->, >=angle 60] (SYDEF) to node[pos=.45,edgeLabel]{\small\cite{DBLP:journals/corr/abs-2409-06974}}(LCOM);
%			\draw[->, >=angle 60] (SYDEF) to node[pos=.45,edgeLabel]{\small\cite{Olejar_Szabari.2023}}(RCOM);
%			\draw[->, >=angle 60] (SYDEF) to node[edgeLabel]{\small\cite{Olejar_Szabari.2023}}(PS);
%			
%			\draw[->, >=angle 60] (RLP1) to node {} (FIN);
%			\draw[->, >=angle 60] (RLP1) to node {} (RLP2);
%			\draw[->, >=angle 60] (RLP2) to node {} (RLP3);
%			\draw[->, >=angle 60,bend left] (RLP2) to node {} (RLV1);
%			\draw[->, >=angle 60] (RLP3) to node {} (RLP4);
%			\draw[->, >=angle 60] (RLP4) to node {} (moreRLP);
%			\draw[->, >=angle 60,bend right] (moreRLP) to node {} (REG);
%			
%			\draw[->, >=angle 60] (NIL) to node {} (RLV1);
%			\draw[->, >=angle 60] (RLV1) to node {} (RLV2);
%			\draw[->, >=angle 60] (RLV2) to node {} (moreRLV);
%			\draw[->, >=angle 60,bend right] (moreRLV) to node {} (REG);
%			
%			\draw[->, >=angle 60,bend right] (MON) to node {} (REGQ2);
%			\draw[->, >=angle 60] (REGQ2) to node {} (moreREGQ);
%			\draw[->, >=angle 60] (REGQ2) to node {} (RLV2);
%			\draw[->, >=angle 60,bend right] (moreREGQ) to node {} (REG);
%			\draw[->, >=angle 60] (COMB) to node {} (REGQ2);
%			
%			\draw[-,dashed]  ([xshift=0.7cm]CIRC.south) -- ([xshift=-1cm]CIRC.south);
%			\draw[-,dashed]  ([xshift=-0.9cm,yshift= -0.2cm]STAR.south) -- ([xshift=0.7cm]CIRC.south);
%			\draw[-,dashed]  ([xshift=-2.7cm,yshift=-3.3cm]SUF.south) -- ([xshift=1cm,yshift= -1.8cm]COMB.south);
%			\draw[-,dashed]  ([xshift=1cm,yshift=2.3cm]COMB.north) -- ([xshift=1cm,yshift= -1.8cm]COMB.south);
%			\draw[-,dashed]  ([xshift=1cm,yshift=2.3cm]COMB.north) -- ([xshift=-0.8cm,yshift= -0.3cm]LCOM.south);
%			\draw[-,dashed]  ([xshift=-0.8cm,yshift= -0.3cm]LCOM.south) -- ([xshift=0.8cm,yshift= -0.2cm]STAR.south);
%			\draw[-,dashed]  ([xshift=-0.9cm,yshift= -0.2cm]STAR.south) -- ([xshift=0.8cm,yshift= -0.2cm]STAR.south);
%			\draw[-,dashed]  ([xshift=-2.7cm,yshift=-3.3cm]SUF.south) -- ([xshift=0.6cm,yshift= 1.1cm]RLV2.south);
%			\draw[-,dashed]  ([xshift=-0.9cm,yshift=2.5cm]SUF.south) -- ([xshift=0.6cm,yshift= 1.1cm]RLV2.south);
%			\draw[-,dashed]  ([xshift=-0.9cm,yshift=2.5cm]SUF.south) -- ([xshift=-0.9cm,yshift= -0.2cm]SUF.south);
%			\draw[-,dashed]  ([xshift=0.8cm,yshift=-0.2cm]SUF.south) -- ([xshift=-0.9cm,yshift= -0.2cm]SUF.south);
%			\draw[-,dashed]  ([xshift=0.8cm,yshift=-0.2cm]SUF.south) -- ([xshift=-0.8cm,yshift= 1.2cm]moreRLP.south);
%			\draw[-,dashed]  ([xshift=0.8cm,yshift=1.2cm]moreRLP.south) -- ([xshift=-0.8cm,yshift= 1.2cm]moreRLP.south);
%	\end{tikzpicture}}
%	\caption{Inclusion hierarchy of subregular language families. The dashed line separates the languages where the $k$-ESU problem is NP-hard (above the line) from the polynomial time decidable ones.}
%	\label{fig:hierarchy}
%\end{figure}
%
%In order to investigate the problem $k$-ESU (and $k$-USU) for all these subregular languages, we show the NP-hardness for some of these classes and give polynomial time algorithms for others.
%
%First of all, we start by restricting the classical model of regular languages, DFA, on the number of states, i.e., we investigate the subregular languages $REG_n^Q$ where $n$ is the maximal number of states a DFA is allowed to have.

\section{Preprocessing: Graph-theoretic View on NFAs}\label{sec:preProc}

In the problems discussed in this paper, we consider a regular language $L$, over the alphabet $\Sigma$, with $|\Sigma|=\sigma$, given either as a regular expression or as an NFA. In this section we only consider the case when the language is given as an NFA $A=(Q,\Sigma,q_0,F,\delta)$ with $n$ states and $m$ transitions, and initial state $q_0$. 

We aim to obtain efficient algorithms that, for a given $k$, check whether $L$ contains a word $w$ of universality $\iota(w)\geq k$. In particular, we will discuss two algorithms, one which is FPT with respect to the parameter $n$, and one which is FPT w.r.t. the parameter $\sigma$. In this section, we describe a series of steps that will be executed as preprocessing for both these algorithms, and introduce a series of definitions used in the description of these algorithms.

Firstly, we note that we can assume w.l.o.g. that all states in $A$ are both accessible and co-accessible and that $A$ has a single final state $f$ (i.e, $F=\{f\}$), which is not the origin of any transition (i.e., $\delta(f,a)=\emptyset$ for all $a\in \Sigma$). Indeed, if we are given an arbitrary NFA $A'$, we can transform it, by standard methods (see, e.g., \cite{HopcroftU79}), in linear time in the total size of $A'$ (that is, number of states plus number of transitions), and obtain an automaton $A$ for which these assumptions hold. Clearly, for $A$, we also have that $\sigma\leq m\leq n^2 \sigma$ (as for each pair of states $(q_1,q_2)$, we can have at most $\sigma$ transitions from $q_1$ to $q_2$, one for each letter, and, for each letter, there should be at least one transition labelled with that letter). 

We now make several remarks on NFAs that are useful for our results. 

Each NFA $A$ can be seen canonically as a directed graph $G_A$, whose vertex-set is the set $Q$ of states of $A$, and there is an edge from state $q_1$ to state $q_2$ in the graph $G_A$ if an only if there is a transition from $q_1$ to $q_2$ in $A$. We recall the following lemma, see, e.g. \cite{Tarjan72}. \looseness=-1

\begin{lemma}\label{lem:stronglyConnected}
Given an NFA $A$, we can compute in $O(n+m)$ time the decomposition of the associated graph $G_A$ in strongly connected components ${\mathcal C}_1, \ldots, {\mathcal C}_e$.
\end{lemma}
The complexity of this algorithm is determined by the computation of the graph $G_A$ from $A$, which can be done in $O(n+m)$ time, and then the usage of Tarjan's algorithm \cite{Tarjan72} for computing the strongly connected components ${\mathcal C}_1, \ldots, {\mathcal C}_e$ which also requires $O(n+m)$ time. We can also compute, within the same time complexity, the directed acyclic graph $S(A)$ of the strongly connected components of $G_A$: it has the vertices $\{1,\ldots,e\}$, corresponding to the strongly connected components ${\mathcal C}_1, \ldots, {\mathcal C}_e$ of $G$, respectively, and there is an edge from $i$ to $j$, for $i,j\in [e]$, if and only if there is an edge from a vertex of ${\mathcal C}_i$ to some vertex of ${\mathcal C}_j$. 

%\todo[inline]{Maybe add here how $G_A$ is obtained from $A$.}
 We can assume that each strongly connected component produced in this algorithm is output as a list of vertices, and, for each vertex, the list of the edges leaving that vertex. For a state $q\in Q$, we set $S(q)=i$ if ${\mathcal C}_i$ is the strongly connected component of $G_A$ which contains state~$q$. 
 
The decomposition of $G_A$ in strongly connected components canonically corresponds to a decomposition of the NFA $A$ in strongly connected components: for $i\in [e]$, the component ${\mathcal C}_i$ of $A$ contains the states corresponding to the vertices of the component ${\mathcal C}_i$ of $G_A$, as well as all the transitions between them. The main difference between the components of $A$ and those of $G_A$ is that in a component of $A$ we might have multiple transitions between two states, while in the respective component of $G_A$ there is at most one edge from one vertex to another. Clearly, we can compute this decomposition of $A$ in strongly connected components in $O(n+m)$ time.

This concludes the description of the preprocessing steps performed at the beginning of our algorithms. 
%Whenever needed, we can extend this preprocessing by computing, in overall time $O(n^2+m)$, the set $E_{i,j}$, containing all transitions $(q_1,a,q_2)$ (i.e., $q_2\in \delta(q_1,a)$) where $q_1$ is a state from $ {\mathcal C_i}$ and  $q_2$ from $ {\mathcal C_j}$, for all $i,j\in [e]$. 
%\todo[inline]{Maybe add here how $E_{i,j}$ is computed.}

Other graph-theoretic notions can be transferred canonically from $G_A$ to~$A$. Recall that a walk in the NFA $A$, originating in state $q$ and with target $q_n$, is a sequence of transitions $\beta=(q,a_1,q_1)(q_1,a_2,q_2)\cdots (q_{n-1},a_n,q_n)$, where  $q_i\in Q$, $a_i\in \Sigma \cup\{\epsilon\}$ for $i\in [n]$, and $q_i\in \delta(q_{i-1},a_i)$ for $i\geq 2$, and $q_1\in \delta(q,a_1)$. The label of $\beta$ is the word $\labels(\beta)=a_1\cdots a_n$. If $q=q_n$, then $\beta$ is called a cycle.

It is not hard to see that, for each state $q$, there is a cycle, denoted in the following $c_q$, containing $q$ that goes at least once through every transition of the NFA-component ${\mathcal C}_{S(q)}$. Indeed, for each transition $(q_1,a,q_2)$, where both $q_1$ and $q_2$ are in ${\mathcal C}_{S(q)}$, we can follow the walk connecting $q$ to $q_1$, then the transition $(q_1,a,q_2)$, and then follow the walk from $q_2$ to $q$; we then simply take the concatenation of all these cycles, and get $c_q$. So, in the following, for each state $q$, we will use $c_q$ to denote a cycle which goes through $q$ and traverses at least once every transition between states contained in ${\mathcal C}_{S(q)}$; we emphasise already at this point that this $c_q$ is never used in our algorithmic results, so we do not focus on constructing it efficiently, but, rather, it is important to know that such a cycle exists for each~$q$. Also, note that even if $S(q_1)=S(q_2)$, we do not necessarily have that $c_{q_1}=c_{q_2}$, but we do have that $\al(\labels(c_{q_1}))= \al(\labels(c_{q_2}))$. For states $q,q'$ with $S(q)=S(q')$, let $p_{q,q'}$ denote the shortest prefix of $c_q$ (w.r.t. number of transitions) connecting state $q$ to state $q'$ in the NFA $A$. 

A walk expression is:
\begin{itemize}[leftmargin=10pt,itemsep=1cm,parsep=-1cm]
\item a {\em single transition} $(q_1,a_2,q_2)$. This denotes a single one-edge walk, namely $(q_1,a_2,q_2)$. The origin of this walk expression is $q_1$ and the target $q_2$. Transitions are called atomic walk expressions (atoms, for short). 
%\item the cycle $(q[c_q])$. This denotes the walk obtained by following the transitions of the cycle $c_q$, which goes through $q$, zero or more times. The origin of this walk expression is $q$ and the target $q$. Such cycles are also atomic walk expressions (or atoms, for short). 
\item an {\em extended cycle}, written as $(q[c_q]q',b,q'')$, where $q,q',q''\in Q$, $q'$ is a state of $\mathcal C_{S(q)}$, $b\in\Sigma\cup\{\epsilon\}$, and $q''\in \delta(q',b)$. This denotes a set of walks, namely those walks $c_q^i p_{q,q'} (q',b,q'')$ obtained by going $i$ times around the cycle $c_q$ (i.e., following $i$ times the transitions of the cycle $c_q$, starting in $q$), for some $i\geq 0$, then following the path $p_{q,q'}$, and, finally the transition $(q',b,q'')$, which corresponds to $q''\in \delta(q',b)$. The origin of this walk expression is $q$ and the target $q''$. Such walk expressions are also called atomic (or atoms). 
\item a concatenation $\alpha= \alpha_1 \alpha_2$ of walk expressions, such that the origin of $\alpha_2$ is the same as the target of $\alpha_1$. This expression denotes the set containing all walks obtained by concatenating walks denoted by $\alpha_1$ with walks denoted by $\alpha_2$. The origin of $\alpha$ is the origin of $\alpha_1$, the target of $\alpha$ is the target of $\alpha_2$. These are non atomic walk expressions.
		\vspace*{-5pt}
\end{itemize}

\section{FPT-Algorithms for $k$-ESU}\label{sec:FPT}

We assume that we are in the setting defined in Section \ref{sec:preProc}, and use the notations introduced in that section. We begin with a simple observation.
\begin{lemma}\label{lem:infUniv} $L$ contains, for each $i\in \N$, a word $w_i$ of universality $\iota(w_i)\geq i$ if and only if there exists a state $q$ of $A$ such that $\al(\labels(c_q))=\Sigma$. 
\end{lemma}
\ifpaper
\else
\input{proofs/proof_infUniv}
\fi
It is not hard to see that if $L$ does not contain words or arbitrarily large universality then $\iota(w)\leq n$ for all $w\in L$.

The following lemma follows immediately from the preprocessing described in Section \ref{sec:preProc} and shows that we can test this property efficiently.
\begin{lemma}\label{lem:cycles} We can compute in $O(m+n)$ time the sets $V_i\subseteq \Sigma\cup \{\epsilon\}$ of all labels of transitions of the strongly connected component ${\mathcal C}_i$ of $A$, for $i\in [e]$. We can then access in $O(1)$ the set $V_{S(q)}$ with $\al(\labels(c_q))=V_{S(q)}$, for all $q\in Q$.
\end{lemma}
\ifpaper
\else
\input{proofs/proof_cycles}
\fi

Therefore, as a first main consequence of the previous lemma, we can test efficiently the existence in $A$ of a state $q$ such that $\al(\labels(c_q))=V_{S(q)}=\Sigma$, as in Lemma \ref{lem:infUniv}. If such a state exists, then we can trivially answer to $k$-ESU, for the input NFA $A$, positively, in polynomial time (in the size of $A$). 

So, let us assume, from now on, that there is no state $q$ with $\al(\labels(c_q))=\Sigma$. We emphasise that Lemma \ref{lem:cycles} allows us to compute in polynomial time, for each state $q\in Q$, only the set $V_{S(q)}= \al(\labels(c_q))$; as already mentioned in the previous section, we do not compute effectively the cycle $c_q$ (we just collect for each $q$ the letters which label all the transitions in its strongly connected component).  However, in the following, in our combinatorial proofs, we will still make use of the notation $c_q$, as introduced above. Since there is no transition leaving the final state $f$ of $A$, $V_{S(f)}=\emptyset$ and $c_f$ is the empty walk.

We will now move on and describe our main results: the first FPT algorithm w.r.t. the parameter $n$ for deciding $k$-ESU, and a more efficient (compared to the similar algorithm presented in \cite{regunivpaper}) FPT algorithm w.r.t. parameter $\sigma$. In both cases, we assume that $L$ does not contain words of arbitrarily large universality, so we can also assume that $k\leq n$, as explained above. 

%\vspace*{-10pt}
%\subsubsection*{
\medskip

\noindent \textbf{FPT Algorithm w.r.t. $n$.}
To begin with, we show the following theorem:
\begin{theorem}\label{thm:reducedwalkExpressions}
If $L$ contains a word $w$ with $\iota(w)=k$ then there exists a word $u\in L$ with $\iota(u)\geq k$, which is the label of a walk denoted by a walk expression of the form $(q_0[c_{q_0}]q_0',b_1,q_1)(q_1[c_{q_1}]q_1',b_2,q_2)\cdots (q_{h-1}[c_{q_{h-1}}]q'_{h-1},b_h,q_h)$, where: $h\leq n$; $q'_i$ belongs to ${\mathcal C}_{S(q_i)}$ for all $i\in [h-1]$; $S(q_i)\neq S(q_j)$, for all $i\neq j$; and $q_h=f$ is the final state of $A$. 
\end{theorem}
%\ifpaper
%\else
\input{proofs/proof_reducedPathExpressions}
%\fi

Note that we will not use Theorem \ref{thm:reducedwalkExpressions} as an algorithmic tool. It just shows that to identify the maximum universality index over the words of $L$ it is enough to consider words $w$ of maximum universality which label walks denoted by walk expressions $(q_0[c_{q_0}]q_0',b_1,q_1)\cdots (q_{h-1}[c_{q_{h-1}}]q'_{h-1},b_h,q_h)$, where: $h\leq n$; $q'_i$ belongs to $S(q_i)$ for all $i\in [h-1]$; $S(q_i)\neq S(q_j)$, for all $i\neq j$; and $q_h=f$ is the final state of $A$. In the following, we show that the search space for the words $w\in L$ with maximum universality index can be restricted further. In particular, our goal is to show that, in order to compute the maximum universality of a word accepted by $A$ along a walk described by expressions as the ones above, it is not important how many times a cycle is traversed, but it is only important to know the states $q$ along this walk and their corresponding sets $V_{S(q)}$. 

Before stating our next result, note that the walks denoted by an expression $\beta'=(q_0[c_{q_0}]q_0',b_1,q_1)(q_1[c_{q_1}]q_1',b_2,q_2)\cdots (q_{h-1}[c_{q_{h-1}}]q'_{h-1},b_h,q_h)$ are exactly the walks $\beta=c^{i_0}_{q_0}p_{q_0,q'_0}(q'_0,,b_1,q_1)\cdots c^{i_{h-1}}_{q_{h-1}}p_{q_{h-1}, q'_{h-1}}(q_{h-1},b_h,q_h)$, where $i_0,\ldots,i_{h-1}$ are non-negative integers. Our next result analyses certain factors of such walks.

\begin{lemma}\label{lem:decomposition}
Let $w$ be a word with $\iota(w)=k$, which labels a walk \\
\centerline{$\beta=c^{i_1}_{q_1}p_{q_1,q'_1}(q'_1,b_2,q_2)c^{i_2}_{q_2}p_{q_2,q'_2}(q'_2,b_3,q_3)\cdots c^{i_{t-1}}_{q_{t-1}}p_{q_{t-1},q'_{t-1}}(q'_{t-1},b_t,q_t)c^{i_{t}}_{q_t}$,} 
where $q'_i$ is a state of ${\mathcal C}_{S(q_i)}$ for all $i\in [t]$, and $S(q_i)\neq S(q_j)$ for $i\neq j$. 

Then, there exists a word $w'=w'_1\cdots w'_k$ and integers $s_0,s_1,\ldots,s_k$ such that:
\begin{itemize}[leftmargin=10pt,itemsep=1cm,parsep=-1cm]
\item $1=s_0<s_1<\ldots<s_k=t$
\item For $i\in [k]$, $w'_i$ is $1$-universal and labels the walk:\\
\hspace*{-10pt} $c_{q_{s_{i-1}}} p_{q_{s_{i-1}},q'_{s_{i-1}}}(q'_{s_{i-1}},b_{s_{i-1}+1},q_{s_{i-1}+1})\cdots c_{q_{s_i-1}}  p_{q_{s_i-1},q'_{s_i-1}} (q'_{s_i-1},b_{s_i},q_{s_i})c_{q_{s_i}}.$
		\vspace*{-5pt}
\end{itemize}
\end{lemma}
%\ifpaper
%\else
\input{proofs/proof_decomposition}
%\fi


Therefore, by Lemma \ref{lem:decomposition}, to compute the maximum universality index over the words of $L$ it is enough to identify a word $w'\in L$ of maximum universality that labels some walk obtained by concatenating several subwalks of the form $c_{q_1}p_{q_1,q'_1} (q'_1,b_2,q_2)\cdots c_{q_{h-1}}p_{q_{h-1},q'_{h-1}}(q'_{h-1},b_h,q_h)c_{q_h}$, where: $h\leq n$; $q'_i$ belongs to $S(q_i)$ for all $i\in [h-1]$; $S(q_i)\neq S(q_j)$, for all $i\neq j$; and $q_h=f$ is the final state of $A$.
The key observation is that, in fact, to find such a word of maximum universality, it is enough to know the sequence of states $q_1,\ldots,q_h$ as above. We will explain now how this is done efficiently. 

\begin{lemma}\label{lem:matching}
Given a sequence of $h<n$ states $q_1\cdots q_h$, such that $S(q_i)\neq S(q_j)$ for all $i\neq j$, we can decide in $O(m+n\sigma \sqrt{n})$ time whether there exist states $g_1,\ldots, g_h$ and $g'_1,\ldots, g'_h$, with $g_1=q_1$, $S(g_i)=S(g'_i)=S(q_i)$ for all $i\in [h]$, and the walk $\beta = c_{q_1}p_{q_1,g'_1} (g'_1,b_2,g_2)\ldots c_{g_{h-1}}p_{g_{h-1},g'_{h-1}}(g'_{h-1},b_h,g_h)c_{g_h}p_{g_h,q_h}$ such that $\labels(\beta)$ is $1$-universal. 
\end{lemma}
%\ifpaper
%\else
\input{proofs/proof_matching}
%\fi

Note that in Lemma \ref{lem:matching} we do not compute the sequence $g_1\cdots g_h$, we just decide whether there is a walk from $q_1$ to $q_h$, going through the strongly connected components of $q_2,\ldots,q_{h-1}$, which is labelled by a $1$-universal word. 

Now, we can state a result which is the main building block of our algorithm.
\begin{lemma}\label{lem:algo_one_seq}
Given a sequence $q_1\cdots q_h$ of $h< n$ states with $q_h=f$ and $S(q_i)\neq S(q_j)$, for all $i\neq j$, we can compute in $O(n(m+ n\sigma \sqrt{n}))$ time the maximum integer $k$ for which there exists a walk $\beta$ with origin $q_1$ and target $q_h$ such that $\labels(\beta)$ is $k$-universal and $\beta$ goes through the strongly connected components of $q_1,\ldots,q_h$, and through no other strongly connected component. 
\end{lemma}
\ifpaper
The idea of the algorithm introduced in this proof is to iteratively use Lemma \ref{lem:matching}, within a greedy strategy. We use Lemma \ref{lem:matching} to identify the shortest prefix $q_1\cdots q_i$ of $q_1\cdots q_h$ for which there is a path from $q_1$ to $q_i$, going through the strongly connected components of $q_2,\ldots,q_{i-1}$, which is labelled by a $1$-universal word. If such a prefix is found, we repeat this process for $q_i \cdots q_h$. We return the number of times we can successfully execute this process. 
\else
\input{proofs/proof_algo_one_seq}
\fi

We can now state the main result of this section.
\begin{theorem}\label{thm:FPT_states}
Given a regular language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as an NFA $A$ with $n$ states, we can solve $k$-ESU in $O(2^nn(m+ n\sigma\sqrt{n}))$ time. That is, in the case when the input is given as an NFA, $k$-ESU is FPT w.r.t. the number $n$ of states of the input NFA.
\end{theorem}
\ifpaper
\else
\input{proofs/proof_FPT_states}
\fi
The algorithm of this theorem considers each set of states $\{q_0,f\}\cup \{q_1,\ldots,q_{h-1}\}$ of $A$, sorts it w.r.t. the topological sorting of $S(A)$ to obtain the sequence $q_0q_1\ldots q_{h-1}f$, and then uses Lemma \ref{lem:algo_one_seq} on it, if the prerequisites of that lemma apply. We return the largest universality index computed for such a subsequence. \looseness=-1

Note that Theorem \ref{thm:FPT_states} shows that $k$-ESU can be solved by an FPT-algorithm w.r.t. the number of states of the input NFA. Moreover, as $m\in O( n^2\sigma)$, $k$-ESU can be solved in linear time $O(\sigma)$ for NFAs with $n\in O(1)$. 
%The following corollary is now immediate. 
%
%\begin{corollary}\label{thm:FPT_states}
%Given a finite language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as an acyclic NFA $A$ with $n$ states, we can solve $k$-ESU in $O(2^n n^3\sigma^{1.5})$ time. 
%\end{corollary}
%\ifpaper
%\else
%\input{proofs/proof_FPT_states_acyclic}
%\fi
%

%\subsection{Subregular languages for which $k$-ESU is NP-complete}
%We continue by investigating the subregular languages that are generated by a right-linear grammar with at most $n$ production symbols, namely $RL_n^P$ (the restriction on the number of terminal symbols $RL_n^\Sigma$ will be covered with nilpotent languages).
%
%\begin{remark}
%	The problem $k$-ESU is NP-complete for right-linear grammars, too since every NFA $\mathcal{A} = (Q,\Sigma,\delta, q_0,F)$ can be transformed to a right-linear grammar $G = (Q,\Sigma,P,q_0)$ by adding every transition as a production, i.e., for all $q,p \in Q, x \in \Sigma$ with $\delta(q,x) = p$ we add a production $q \to xp$ and the rule $q \to \varepsilon$ for all $q \in F$. 
%	
%	Further, the FPT algorithm presented for NFA that is polynomial in $\sigma$ and exponential in $|Q|$ also applies for right-linear grammars with a fixed number of productions, i.e., $k$-ESU for $RL_n^P$ is polynomial time decidable for fixed $n \in \N$.
%\end{remark}
%
%Now, we continue with the other subregular languages and their immediate NP-hardness results.
%
%\begin{remark}
%	From \cite{regunivpaper} we can apply the same reduction to a suffix closed automaton and conclude that the $k$-ESU problem for suffix-closed languages $\SUF$ is NP-hard while the $k$-USU problem can be solved in polynomial time (same with prefix closed). 
%	%  Further, let $L_{STAR} = H^*, L_{LCOM} = EG^*, L_{RCOM} = G^* H, L_{2COM}= EG^* H$ be star, left-, right, and two-sided comet, resp.~for some regular languages $E,H$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$. Since the decision of the $k$-ESU problem depends on solving this problem for $E,G$ and $H$, resp.~it follows that this problem is NP-hard for stars, left-, right- and two-sided-comets.
%\end{remark}
%
%Using the inclusion properties shown in Figure~\ref{fig:hierarchy} we can conclude the NP-hardness of $k$-ESU for several subregular languages that include the finite languages.
%
%\begin{corollary}
%	$k$-ESU is NP-hard for $\NIL,\DEF, \ORD, \NC, \SF, \PS$ languages.
%\end{corollary}
%
%\begin{corollary}
%	$k$-ESU is NP-hard for $RL_n^P$ for all $n \in \N$.
%\end{corollary}
%\ifpaper
%\else
%\input{proofs/proof_k-ESU_RLNP}
%\fi
%
%%\begin{proposition}
%%	Let $L = A \cup \Sigma^* B$ be a finite definite language for $A,B \subseteq \Sigma^*$ finite. If $B \neq \emptyset$, we can positively decide $k$-ESU and $k$-USU in constant time for any $k\in \N$. %Otherwise the problem of $k$-ESU is NP-hard and $k$-USU is decidable in polynomial time.
%%	
%%	Further, for a symmetric definite language $L = E \Sigma^* H$ with regular languages $E,H$, we positively decide $k$-ESU and $k$-USU any $k\in \N$ if $E,H \neq \emptyset$ and negatively otherwise.
%%\end{proposition}
%%\begin{proof}
%%	If $B \neq \emptyset$ ($E,H \neq \emptyset$, resp. for symmetric definite languages) the claim follows analogously to Remark~\ref{monoidal+combinatorial} for combinational languages using a case distinction on $B\neq \emptyset$ ($E,H \neq \emptyset$).
%%	%  	
%%	In the case of finite definite languages.
%%	If $B = \emptyset$ then $L$ is a finite language. Thus, the $k$-ESU problem is NP-hard and $k$-USU polynomial time decidable by \cite{regunivpaper}.
%%	
%%	In the case of symmetric definite languages and $E = \emptyset$ or $H = \emptyset$ we immediately conclude $L = \emptyset$.\qed
%%\end{proof}
%%
%%\begin{remark}
%%	By \cite{fleischmann2021scattered} the computation of a word's circular universality index (the maximal value $k$ such that a conjugate of the word is $k$-universal) relies on the computation of its universality index. Thus, the $k$-ESU problem for $\CIRC$ remains NP-hard following \cite{regunivpaper}.
%%\end{remark}
%%
%%  \begin{proposition}
%%	For left-/right-/two-sided-comet languages $L = EG^*$ ($L = G^*H, L = EG^*H$ resp.) for regular languages $E,G,H$ with $G \notin \{\emptyset,\{\varepsilon\}\}$.Let $G$ be given by an automaton $\mathcal{A} = (Q,\Sigma,q_0,\delta,F)$ and $k \in \N$. If $\bigcup_{w \in G}\al(w) = \Sigma$ then the problem $k$-ESU is decidable in time ???. Otherwise, the decision of $k$-ESU is NP-hard.
%%\end{proposition}
%%\begin{proof}
%%	For the proof, we consider two sided comets. The result for left- and right-sided comets can be proven analogously. Let $L$ be a two-sided comet. Then there exist regular languages $E,G,H \subseteq \Sigma^*$ with $G \notin \{\emptyset,\{\varepsilon\}\}$. Using a BFS we determine the set $\bigcup_{w \in G}\al(w)$ of all letters of transitions that belong to walks that contain final states in time $O(|Q|\sigma)$. \todo{I am not sure on the maximal cardinality of the transition function for NFAs since there might be $\varepsilon$-Edges}
%%	If $\bigcup_{w \in G}\al(w) = \Sigma$, then $G^*$ does contain $k$-universal words for every $k\in \N$, i.e., $k$-ESU can be decided positively. If $\bigcup_{w \in G}\al(w) \subset \Sigma$ then the universality of $L$ depends on deciding the $k$-ESU problem for $E,H$, i.e., the problem is NP-hard in this case by \cite{regunivpaper}.\qed
%%\end{proof}
%
%\begin{remark}
%	The problem of deciding $k$-ESU for $\STAR$ $L = H$ for a regular language $H$ falls back to the problem of checking for the existence of a $1$-universal word in $H$ which is NP-hard by \cite{regunivpaper}. By inclusion, the NP-hardness of $\UF$ follows.
%\end{remark}
%
%\subsection{Subregular languages with $k$-ESU polynomial time decidable}
%
%Now we continue with some strongly restricted subsets of regular languages for which the $k$-ESU problem is polynomial time decidable.
%
%\begin{remark}\label{monoidal+combinatorial}
%	For monoidal and combinational languages and any $k\in \N$, we can positively decide $k$-ESU since $\Sigma^*$ and $\Sigma^*X$ for $X \subseteq \Sigma$ contain $k$-universal words for any $k$ if $X\neq \emptyset$ and negatively decide $k$-USU unless $k=0$ or $k=\sigma=1$ and $X=\Sigma$, since $\varepsilon$ (or $\varepsilon X$) is contained in both language classes, resp. which witnesses a non-$k$-universal word.
%\end{remark}
%
%\subsubsection{Commutative Languages}
%
%Also for commutative languages, the $k$-ESU problem can be solved in polynomial time.
%
%\begin{lemma}
%	\label{prop:commutative_finite_k}
%	For a $k \in \N$ and a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, the $k$-ESU problem can be decided in $O(\min(\sigma k, n\sigma))$ time.
%\end{lemma}
%\ifpaper
%\else
%\input{proofs/proof_commutative_finite_k}
%\fi
%
%\begin{lemma}
%	\label{prop:commutative_infinite_k}
%	For a $k \in \N$ and a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, we can determine if there is a positive solution to the $k$-ESU problem for every $k \in \mathbb{N}$ in $O(n \sigma)$ time.
%\end{lemma}
%\ifpaper
%\else
%\input{proofs/proof_commutative_infinite_k}
%\fi
%
%\begin{theorem}
%	For a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, we can find the maximal $k$ such that $k$-ESU is fulfilled in $O(n \sigma \log n)$ time.
%\end{theorem}
%\ifpaper
%\else
%\input{proofs/proof_maximal_k_commutative_language}
%\fi
%
%%{\color{orange}
%%	\subsection{results we might not need anymore}
%%	
%%	\begin{proposition}
%%		Let $L \in \NIL$ and $k \in \N$. The problem of deciding $k$-ESU is NP-complete and $k$-USU solvable in polynomial time.
%%	\end{proposition}
%%	\begin{proof}
%%		If $L$ is finite the result follows by \cite{regunivpaper}.
%%		In the case that $\Sigma^{\ast}\backslash L$ is finite there exists a $k' \in \N$ such that $\Univ_{<k'} \not \subseteq L$ and $\Univ_{\geq k'} \subseteq L$ holds. Thus, for all $k \geq k'$ we can answer $k$-USU positively and for $k < k'$ in polynomial time using the algorithmic approach from \cite{regunivpaper}. Similar, the NP-completeness of $k$-ESU for all $k<k'$ follows from \cite{regunivpaper} and can be positively decided for $k \geq k'$.\qed
%%	\end{proof}
%%	
%%	\begin{remark}
%%		If $L(\mathcal A)$ is finite $|L(\mathcal A)|$ can still be exponential in $|\mathcal A|$. Hence, checking the universalities of all the words is not necessarily efficient.
%%	\end{remark}
%%	
%%	\begin{remark}    
%%		The $k$-ESU problem for non-counting languages can be decided positively for all $k$ if there exists a $1$-universal word within the language (otherwise negatively). This problem is NP-hard by \cite{regunivpaper}.
%%		%	This can be checked in polynomial time by performing a BFS from the initial state to all accepting states while ignoring the loops. 
%%	\end{remark}%\todo[inline]{But checking for a 1-universal word is already NP-hard by our Isaac paper. Why should it be easier for non-counting languages?}
%%	
%%	
%%}
\begin{proof}
	If such a state $q$ exists, then we get immediately the result, given that $q$ is both accessible and co-accessible. To get a word $w_i$ with $\iota(w_i)\geq i$, we follow a path from $q_0$ to $q$, then follow the cycle $c_q$ for $i$ times, and then follow a path from $q$ to the final state of $A$. The converse follows by a pumping argument. Recall that the automaton $A$ has $n$ states and we have in $L$ a word of universality $\iota(w_{n+1})= n+1$. Then $w_n=u_1\cdots u_{n+1}$, where $\al(u_i)=\Sigma$ for all $i\in [n+1]$. Moreover, the word $w_{n+1}$ is accepted along a path $\beta_1\beta_2\cdots \beta_{n+1}$, where $\labels(\beta_i)=u_i$ for all $i\in [n+1]$. By the pigeonhole principle, there exist $i$ and $j$, with $i,j\in [n+1]$ and $i<j$, such that the origin of $\beta_i$ and $\beta_j$ is the same state $q$. Then, $c=\beta_i\cdots \beta_{j-1}$ is a cycle that goes through $q$ and contains only transitions of ${\mathcal C}_{S(q)}$, so this means that $\al(\labels(c_q))=\Sigma$. \qed
\end{proof}
\begin{proof}
We execute first the preprocessing steps from Section \ref{sec:preProc}. Then, for each strongly component ${\mathcal C}_i$ of $A$, we initialize $V_i=\emptyset$. We then go through the set of transitions of $A$, and for every transition $(q_1,a,q_2)$ with $S(q_1)=S(q_2)$, we add $a$ to $V_{{S(q_1)}}$ (note that these sets might contain $\epsilon$). This can be done in $O(m)$ time. Finally, for some state $q\in Q$, we can access $V_q$ by accessing $V_{S(q)}$ and, if needed, removing $\epsilon$ from $V_{S(q)}$.
The conclusion follows.	
	\qed 
\end{proof}
\begin{proof}
	Let us consider a walk $\beta=(q_0,a_1,q_1)(q_1,a_2,q_2)\cdots (q_{r-1},a_r,q_r)$ with label $w$, where $q_r=f$. We will rewrite this walk in several steps, in order to derive the result from the statement.
	
	Clearly, the walk expression \\
	\centerline{$\beta'=(q_0[c_{q_0}]q_0,a_1,q_1)(q_1[c_{q_1}]q_1,a_2,q_2)\cdots (q_{r-1}[c_{q_{r-1}}]q_{r-1},a_r,q_r)$} 
	denotes walks whose labels are words $w'$ for which $\iota(w')\geq \iota(w)$ (as all such words have $w$ as subsequence). Obviously, $w$ is the label of some walk (namely $\beta$) denoted by the walk expression $\beta'$.
	
	We iterate the following process on $\beta'$:
\begin{itemize}[leftmargin=10pt,itemsep=1cm,parsep=-1cm]
		\item Firstly, find the leftmost atom $(q_1[c_{q_1}]q_1,a,q'_1)$ of the walk expression $\beta'$ such that there exists another atom $(q_2[c_{q_2}]q_2,b,q'_2)$ in $\beta'$, with $S(q_1)=S(q_2)$. Note that, if such states $q_1,q_2$ exist, then $q_1\neq f\neq q_2$. 
		\item Secondly, find the rightmost atom  $(q_2[c_{q_2}]q_2,b,q'_2)$, with $S(q_2)=S(q_1)$. Thus: $\beta' = x (q_1[c_{q_1}]q_1,a,q'_1) z (q_2[c_{q_2}]q_2,b,q'_2) y$, where neither $x$ nor $y$ contain atoms originating with a state $q$ of ${\mathcal C}_{S(q_1)}$ and $z$ is a walk visiting only states in ${\mathcal C}_{S(q_1)}$. Rewrite $\beta'$ as $\beta' = x (q_1[c_{q_1}]q_2,b,q'_2) y$. Note that no state $q$ of ${\mathcal C}_{S(q_1)}$ may appear in $\beta'$ as the origin of a walk expression, except $q_1$. Moreover, if a state $g_1$ is the origin of some atom of $x  (q_1[c_{q_1}]q_2,b,q'_2) $, then there is no other atom of $\beta'$ whose origin is some state $g'$ of ${\mathcal C}_{S(g)}$. 
		\vspace*{-5pt}
	\end{itemize}
	
	Let $w_0=w$. Now, we claim that at the end of the $i^\text{th}$ iteration, for $i\geq 1$, there exists a word $w_i$ which labels one of the walks denoted by the current expression $\beta'$ (i.e., as computed at the end of the respective iteration) such that $\iota(w_i)\geq \iota(w_{i-1})$. Indeed, we can obtain $w_i$ as follows: we take the prefix of $w_{i-1}$ corresponding to the walk expression $x$, then we follow transitions of the cycle $c_{q_1}$ at least $2|z|+1$ times (which is more than enough to cover all the factors of $z$ that had some state $q$ of ${\mathcal C}_{S(q_1)}$ as origin), then we follow the transition $(q_2,b,q'_2)$, and end with the suffix of $w_{i-1}$ corresponding to the expression $y$. 
	
	The above process is finite (in each step we reduce the number of atoms of $\beta'$), and shows how each walk $\beta$, with label $w$, is transformed into a walk expression $\beta'=(q_0[c_{q_0}]q_0',b_1,q_1)\cdots (q_{h-1}[c_{q_{h-1}}]q'_{h-1},b_h,q_h)$, where: $h\leq n$; $q'_i$ belongs to ${\mathcal C}_{S(q_i)}$ for all $i\in [h-1]$; $S(q_i)\neq S(q_j)$, for all $i\neq j$; and $q_h=f$. Moreover, as shown, there exists at least one word $u$ labelling a walk denoted by the expression $\beta'$, derived at the end of this process, such that $\iota(u)\geq \iota(w)$. 
	\qed\end{proof}
\begin{proof}
	As $\iota(w)\geq k$, we have that there exist words $w_1,\ldots, w_k$, with $w=w_1\cdots w_k$ and $\iota(w_i)=1$ for all $i\in [k]$. Let $\beta_i$ be the subwalk of $\beta$ labelled by $w_i$. We have $\beta=\beta_1\beta_2\cdots \beta_k$. For simplicity, let $q'_t=q_t$, $p_{q_t,q'_t}=\epsilon$, and $s_0=1$. \looseness=-1
	
	For $i\in [k]$, let $s_i\geq s_{i-1}$ be the smallest integer such that $\beta_i$ is a factor (that is, contiguous subwalk) of $c^{i_{s_{i-1}}}_{q_{s_{i-1}}} p_{q_{s_{i-1}},q'_{s_{i-1}}}(q'_{s_{i-1}},b_{s_{i-1}+1},q_{s_{i-1}+1})\cdots c^{i_{s_i}}_{q_{s_i}} p_{q_{s_i},q'_{s_i}}$. It is not hard now to see that $s_{i}>s_{i-1}$ holds, as $\al(\labels(c_{q_{s_{i-1}}} p_{q_{s_{i-1}},q'_{s_{i-1}}})) = \al(\labels(c_{q_{s_{i-1}}} ))\subsetneq \Sigma = \al(\labels(\beta_i))= \al(w_i)$. 
	
	Let us now define, for all $i\in [t]$, the walk $\beta'_i$ as:\\
\centerline{$ c_{q_{s_{i-1}}} p_{q_{s_{i-1}},q'_{s_{i-1}}}(q'_{s_{i-1}},b_{s_{i-1}+1},q_{s_{i-1}+1})\cdots c_{q_{s_i-1}}  p_{q_{s_i-1},q'_{s_i-1}} (q'_{s_i-1},b_{s_i},q_{s_i})c_{q_{s_i}}$.}
	Also, let $w'_i=\labels(\beta'_i)$. Clearly, $\al(w'_i)=\al(w_i)=\Sigma$, as $\al(\label(c^{i_{s_i}}_{q_{s_i}} p_{q_{s_i},q'_{s_i}})=\al(\label(c_{q_{s_i}}p_{q_{s_i},q'_{s_i}})=\al(\label(c_{q_{s_i}})$. The conclusion follows, for $w'=w'_1\cdots w'_k$. 
	\qed 
\end{proof}
\begin{proof}
	Firstly, we can compute in $O(n+m)$ time the sets $V_{q_{i},q_{i+1}}\subseteq \Sigma\cup\{\epsilon\}$ of labels of transitions from states of ${\mathcal C}_{S(q_i)}$ to states of ${\mathcal C}_{S(q_{i+1})}$, for all $i\in [h-1]$. 
	If there exists $i\in [h-1]$ such that $V_{q_{i},q_{i+1}}=\emptyset$, then we answer the considered problem negatively.  Let us assume, in the following, that this is not the case.
	
	Then, we compute the sets $V_{S(q_i)}$, for all $i\in [h]$, as described in Lemma \ref{lem:cycles}, and the set $V=\bigcup_{i\in h} V_{S(q_i)}$. This takes $O(n+m)$ time. Further, we want to see if there is a way to identify states $g_2,\ldots, g_h,$ $g'_1,\ldots, g'_h$, and the letters $b_1,\dots, b_h$, such that $\beta = c_{q_1}p_{q_1,g'_1} (g'_1,b_2,g_2)\ldots c_{g_{h-1}}p_{g_{h-1},g'_{h-1}}(g'_{h-1},b_h,g_h)c_{g_h}p_{g_h,q_h}$ is $1$-universal. In other words, $ \Sigma\setminus V\subseteq \{b_1,\dots, b_h\}$. 
	
	The first case is when $V=\Sigma$. In that particular case, all walks $\beta = c_{q_1}p_{q_1,g'_1} (g'_1,b_2,g_2)\cdots c_{g_{h-1}}p_{g_{h-1},g'_{h-1}}(g'_{h-1},b_h,g_h)c_{g_h}p_{g_h,q_h}$, fulfilling the conditions from the statement, are labelled by $1$-universal words, and the considered problem can be answered positively. 
	
	The second case is if $\Sigma\subset V$ and $|V| >h$; then, the answer is negative.
	
	Otherwise, we define a bipartite graph $G$ as follows:
\begin{itemize}[leftmargin=10pt,itemsep=1cm,parsep=-1cm]
		\item The set of vertices is defined by the following two disjoint sets: on the one side, we have the set $[h-1]$ (so the vertices are integers $i\in [h-1]$)  and, on the other side, the set $\Sigma \setminus V$ (so the vertices are letters $b\in \Sigma \setminus V$).
		\item There exist an edge between vertex $i\in [h-1]$ and vertex $b\in \Sigma \setminus V$ if and only if $b\in V_{q_i,q_{i+1}}$. $G$ contains no other edges.
				\vspace*{-5pt}
	\end{itemize}
	
	If $\nu=|\Sigma \setminus V|$, we have $\nu \leq h$, so we can compute in $O(h\nu \sqrt{h+\nu})\subseteq O(n\sigma\sqrt{n})$ time a maximum-cardinality bipartite matching \cite{HopcroftK73}. If the cardinality of this matching is $\nu$ (that is, every letter-vertex of $G$ is covered by one edge of the matching), then we proceed as follows. 
	We first define, for $i\in \{2,\ldots,h\}$, the letter $b_i$: if $(i-1,b)$ is an edge of the matching, then $b_i=b$; otherwise, $b_i$ is an arbitrary element of $ V_{q_{i-1},q_i}$. In both cases, we set $g'_{i-1}\in V_{S(q_{i-1})}$ and $g_i\in V_{S(q_{i})}$ to be states connected by the letter $b_i$. It is now immediate that the path  $\beta = c_{q_1}p_{q_1,g'_1} (g'_1,b_2,g_2)\cdots c_{g_{h-1}}p_{g_{h-1},g'_{h-1}}(g'_{h-1},b_h,g_h)c_{g_h}p_{g_h,q_h}$ is labelled by an $1$-universal word: each letter of $\Sigma$ is either the label of a transition from a cycle $c_{q_i}$ or of a transition between some states $g'_{i-1}$ and $g_i$. Thus, in this case, we can answer the problem positively. If the cardinality of this matching is strictly smaller than $\nu $, then the problem is answered negatively. In that case, we cannot cover all letters with either transitions of the strongly connected components ${\mathcal C}_{S(q_i)}$, for $i\in [t]$, or the transition between states of these components. 
	
	Therefore, the statement holds.
	\qed \end{proof}
\begin{proof}
	The problem can be solved by a dynamic programming algorithm. We initialise an integer-array $D$ with $n$ elements, where $D[i]=0$ for all $i$.
	
	Firstly, for every $i\in [h]$, we consider $j$ from $1$ to $i$.  We check with Lemma \ref{lem:matching}, for the sequence $q_j\cdots q_i$ whether there exists a path $\beta_{j,i}$ which is $1$-universal and connects $q_i$ to $q_j$, and goes through the strongly connected components of $q_i,\ldots,q_j$, but through no other strongly connected component (as in the statement of the respective lemma). If such a path $\beta_{j,i}$ exists, we set $D[i]=\max\{D[i],D[j]+1\}$. 
	
	It is not hard to show (by induction) that at the end of the iteration for $i=t$, we have that, for all $j\leq t$, the value $D[j]$ equals the maximum number $k_j$ for which there exists a path $\beta_j$, which connects $q_1$ to $q_j$, while going through the strongly connected components of $q_1,\ldots,q_j$, and through no other strongly connected component, such that $\labels(\beta_j)$ is $k_j$-universal. So, at the end of the algorithm, once the iteration for $i=h$ is completed, $D[h]$ equals the maximum number $k$ for which there exists a path $\beta$ connecting $q_1$ to $q_h$, going through the strongly connected components of $q_1,\ldots, q_h$ but through no other strongly connected component, such that $\labels(\beta)$ is $k$-universal (recall that $c_{q_h}$ is empty). 
	
	The running time of this algorithm is $O(n^2(m+ n\sigma \sqrt{n}))$, as it simply executes $O(h^2)$ times the algorithm from Lemma \ref{lem:matching} and $h\leq n$. 
	
	This can be further optimised as follows. To decide whether there exists a path $\beta_{i}$, going through the strongly connected components of $q_1,\ldots,q_i$, whose label is $k$-universal, our algorithm simply identifies the smallest $j$ such that there exist a path $\beta_{j}$, going through the strongly connected components of $q_1,\ldots,q_j$, whose label is $(k-1)$-universal, and then checks the existence of $\beta_{i,j}$ (as defined above) which is $1$-universal. Note that if such a $\beta_{i,j}$ does not exist for the minimal $j$ for which a path $\beta_{j}$ whose label is $(k-1)$-universal, then it will also not exist for any greater $j$. Therefore, a greedy strategy can be used to solve our problem. Using the notations introduced above, we first find the smallest $i_0$ such that there exist a path $\beta_{i_0}$ whose label is $1$-universal. Then, we find the smallest $i_i>i_0$ such that there exist a path $\beta_{i_0,i_1}$ whose label is $1$-universal, and conclude that $i_1$ is the smallest integer such that there exists $\beta_{i_1}$ (obtained by the concatenation of $\beta_{i_0}$ and $\beta_{i_0,i_1}$) whose label is $2$-universal; if there is no position $i$ for which a path $\beta_{i_0,i}$ with $1$-universal label exists, we set $i_1=-1$. We repeat this process, and, for $2\leq j\geq n$, if $i_{j-1}\neq -1$, identify the smallest $i_j$ such that there exists $\beta_{i_j}$ (obtained by the concatenation of $\beta_{i_{j-1}}$ and $\beta_{i_{j-1},i_j}$) whose label is $j$-universal; again, if we do not find any $i_j\leq n$ with the desired property, we set $i_j=-1$. We return the largest $j$ for which $i_j\neq -1$. This process only takes $O(n(m+ n\sigma\sqrt{n}))$ time, as it simply executes at most $O(n)$ times the algorithm from Lemma \ref{lem:matching}.
	Thus, the statement clearly holds.
	\qed\end{proof}
\begin{proof}
	As discussed at the beginning of this section, we can assume that $A$ has a single final state. We process $A$ as in Lemma \ref{lem:cycles} and obtain the strongly connected components of $A$, and the corresponding directed acyclic graph of strongly connected components $S(A)$. We now order the vertices of $S(A)$ topologically (using the standard topological sorting algorithm, which runs in $O(n+m)$ time). Note that ${\mathcal C}_{S(q_0)}$ is always the first strongly connected component in this topological sorting of $S(A)$ (as all states are accessible) and ${\mathcal C}_{S_f}=\{f\}$ is the last component in this sorting. 
		
	We now iterate over all subsets $Q'=\{q_0,f\}\cup \{q_1,\ldots,q_{h-1}\}$ of $Q$; for simplicity, set $q_h=f$ and note that $h< n$. 
	
	For such a set, we check whether $S(q_i)\neq S(q_j)$, for all $i\neq j$; if this is not the case, we consider the next subset of $Q$. This can be done in $O(e)\subseteq O(n)$ time, by marking in an array of length $e$ how many times each integer $i\in [e]$ (that is, label of a strongly connected component) appears in the set $Q'=\{S(q_0),S(f)\}\cup \{S(q_1),\ldots,S(q_{h-1})\}$.
	
	If no two states of the set $Q'$ are part of the same strongly connected component, we sort $Q'$ w.r.t. the topological sorting of $S(A)$ (which can be done in $O(n)$ time, as we already have the topological sorting of $S(A)$). 
	
	After this step, and a potential relabelling of the states, we can assume that $q_{i-1}$ comes before $q_{i}$ in the topological sorting, for all $i\in [h]$, $q_0$ is the first in this order, and $q_h=f$ still holds. Then, we simply use Lemma \ref{lem:algo_one_seq} for the sequence $q_0\cdots q_h$ of $h< n$ states, as the conditions from the statement of this lemma are fulfilled. We then store the maximum value $k$ computed in the respective lemma (over all the considered sequences $q_0\cdots q_h$). This is the largest universality of a word which labels a path connecting $q_0$ to $f$, so the maximum universality of a word of $L$. As the number of the considered subsets is $O(2^n)$, the statement follows based on the complexity of the algorithm of Lemma~\ref{lem:algo_one_seq}.
	\qed \end{proof}
\medskip

\noindent \textbf{FPT Algorithm w.r.t. $\sigma$.} In \cite{regunivpaper} it was shown that we can solve $k$-ESU in $O(n^3 \poly(\sigma) 2^\sigma)$ time. We improve this result and give a linear time solution for $k$-ESU in the case of constant alphabets.
\begin{theorem}\label{thm:FPT_sigma}
Given a regular language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as an NFA $A$ with $n$ states, we can solve $k$-ESU in $O(n + m + m2^\sigma)$ time. 
\end{theorem}
\ifpaper
The algorithm of this theorem uses a dynamic programming approach. If ${\mathcal C}_1=C_{S(q_0)},\ldots, {\mathcal C}_e=\{f\}$ is the topological sorting of $S(A)$, we efficiently compute $D[i][S]$ for $i\in [e]$ and $S\subseteq \Sigma$, the largest universality index of a word with $\al(\r(w))=S$, which labels a walk starting in $q_0$, ending in $C_i$, and going only through the components  ${\mathcal C}_1,\ldots, {\mathcal C}_i$. We then return the largest element of $D[e][\cdot]$.
\else
\input{proofs/proof_FPT_sigma}
\fi


%The following corollary follows. 
%
%\begin{corollary}\label{thm:FPT_sigma_acyclic}
%Given a finite language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as an acyclic NFA $A$ with $n$ states and $m$ transitions, we can solve $k$-ESU in $O(m 2^\sigma)$ time. 
%\end{corollary}
%\begin{proof}
%The algorithm from Theorem \ref{thm:FPT_sigma} works in this case, as well, but we do not need the preprocessing phase. More precisely, each strongly connected component of $A$ consists in one state only, so their topological sorting can be done in $O(n+m)$ time directly, without constructing the graph $G_A$ and the alphabets $V_i$, corresponding to the strongly connected components, are all empty. As the sets $V_{\rightarrow j}$ correspond to the incoming transitions of each state, the entire preprocessing takes $O(n+m)$ time. The dynamic programming part of the algorithm still requires $O(m 2^\sigma)$ time, so the conclusion follows.
%\qed\end{proof}

%We first present a new parametrised algorithm for finite languages defined by an automaton. This algorithm improves the $O(m^3 2^{\sigma})$ given in \cite{regunivpaper} for general automata to $O(m 2^{\sigma})$, where $m$ is the number of transitions in the input automaton, and $\sigma$ is the size of the alphabet.
%
%We motivate this section in two ways. First, we show that any automaton accepting a finite language is acyclic. Secondly, we note that $1$-ESU is NP-Hard for acyclic languages. Thus, this algorithm covers not only an important class of languages, but also provides a new FPT algorithm covering an NP-Hard problem.
%
%\begin{proposition}
%	Any automaton $\mathcal{A}$ accepting a finite language is \emph{acyclic}.
%\end{proposition}
%\ifpaper
%\else
%\input{proofs/proof_finite_language_is_acyclic}
%\fi
%
%\begin{lemma}[Adapted from \cite{regunivpaper}]
%	The $1$-ESU problem is NP-Hard for acyclic languages.
%\end{lemma}
%\ifpaper
%\else
%\input{proofs/proof_k-ESU_acyclic}
%\fi
%
%We now provide our algorithmic result.
%Let $\mathcal{A} = (\Sigma, Q, q_0, F, \delta)$ be an automaton containing $m$ transitions. During the execution of the algorithm, we compute two $Q \times 2^{\sigma}$ sized tables, $U$ and $L$, both indexed by tuples of the form $(q_\ell, s)$ where $q_\ell \in Q$ and $s \subset \Sigma$. The value of $U[q_{\ell}, s]$ is the value such that there exists some word $w \in \Sigma^{*}$ such that $\delta(q_0, w) = q_{\ell}$, $\iota(w) = U[\ell, s]$, $s \subseteq \r(w)$, and, for all other words $w' \in \Sigma^*$, either, $\delta(q_0, w') \neq q_{\ell}$, $\iota(w') \leq U[\ell, s]$, or $\r(w') \not\subseteq s$. The value of $L[\ell, s]$ is $True$ if there exists some word $w \in \Sigma^*$ such that $\delta(q_0, w) = q_{\ell}$ and $s \subseteq \letters(q_{\ell})$. We set $L[0, s]$ to $False$ for every $s \subseteq \Sigma, s \neq \emptyset$ and $True$ for $L[0, \emptyset]$.
%Finally, we assume that each state has a list $P_i$ containing the set of all transitions that end at $q_i$, formally $P_i = \{(q, x) \mid q \in Q, x \in \Sigma, \delta(q, x) = q_i\}$.
%
%% We associate to each state a pair of pointers $b_i$ and $\beta_i$ which will be used for backtracking during the execution of the algorithm. At a high level, we use these pointers to help with the computation of subregular expressions, allowing us to retrieve the data from the relevant part of the dynamic programming tables $U$ and $L$.
%% % Formally, the value of $b_i$ is the index such that:
%% % \begin{itemize}
%% %     \item there exists some word $u \in \Sigma^+$ such that $\delta(q_{b_i}, u) = q_i$,
%% %     \item $q_{b_i}$ contains at least two outgoing transitions, and,
%% %     \item for every prefix of $u$, $u' = u[1, j], j \in [1, \vert u \vert - 1]$, $\delta(q_{b_i}, u')$ has only one outgoing edge.
%% % \end{itemize}
%% % In general, the pointer $b_i$ allows the values of $U[\ell, s]$ and $L[\ell, s]$ to be computed by quickly giving the index of the preceding state to $q_i$.
%% Formally the value of $b_i$ is the label such that there exists some $x \in \Sigma$ such that $\delta(q_{b_i}, x) = q_i$. In the case that $q_i$ has multiple incoming edges, the value of $b_i$ is chosen arbitrarily from the set of all incoming enge
%
%
%%
%%
%% During the execution of the algorithm, we will maintain at each state a pointer $b_i$. Informally, $b_i$ points to the \emph{branching state} immediately preceding $q_i$, i.e. the state with multiple outgoing transitions that is closest to $q_i$. In the case that $q_i$ is the last state from a given branch . Formally, $q_{b_i}$ is the state such that $q_{b_i}$ has at least two outgoing transitions, there exists some $u \in \Sigma^{+}$ where $\delta(q_{b_i}, u) = q_{i}$, and, for any $j \in [1, \vert u \vert - 1]$, the state $\delta(q_{b_i}, u[1, j])$ has only one outgoing transition. Note that even if $q_i$ has multiple outgoing transitions, $b_i$ will not equal $i$.
%%
%% At step $\ell$, we determine the value of $U[\ell, s]$ as:
%
%% \[
%%     U[\ell, s] = \begin{cases}
%%         \max\left( \left(\max_{(q, x) \in Q_{\ell, s}} U[q, s \setminus x]\right), \max_{(q, x) \in P_{\ell}} \left(U[q, s]\right)\right) & s \neq \emptyset\\
%%         \max\left(\max_{(q, x) \in Q_{\ell, \Sigma}} \left(U[\ell, s \setminus x] + 1 \right),  \max_{(q, x) \in P_{\ell}} U[\ell, \emptyset]\right)& s = \Sigma
%%     \end{cases}
%% \]
%% where $Q_{\ell, s} = \{(q, x) \in P_{\ell} \mid x \in s, L[q, s \setminus x] = \text{ True }\}$ for any $s \subseteq \Sigma$.
%% Similarly, the value of $L[\ell, s]$ is defined as:
%% \[
%%     L[\ell, s] = \bigvee_{(q, x) \in P_{\ell}} \left( L[q, s \setminus \{ x \}]\right).
%% \]
%
%\begin{lemma}
%    \label{lem:making_table_L}
%    \[
%    L[\ell, s] = \bigvee_{(q, x) \in P_{\ell}} \left( L[q, s \setminus \{ x \}]\right).
%\]
%\end{lemma}
%\ifpaper
%\else
%\input{proofs/proof_construction_L_table}
%\fi
%
%\begin{lemma}
%    \label{lem:making_table_u}
%    \[
%        U[\ell, s] = \begin{cases}
%            \max_{(q, x) \in P_{\ell, s}} U[q, s \setminus x] & s \neq \emptyset\\
%            \max\left(\max_{(q, x) \in Q_{\ell, \Sigma}} \left(U[\ell, s \setminus x] + 1 \right),  \max_{(q, x) \in P_{\ell}} U[\ell, \emptyset]\right)& s = \emptyset
%        \end{cases}
%    \]
%    where $Q_{\ell, s} = \{(q, x) \in P_{\ell} \mid x \in s, L[q, s \setminus x] = \text{ True }\}$.
%\end{lemma}
%\ifpaper
%\else
%\input{proofs/proof_construction_U_table}
%\fi
%
%\begin{theorem}
%    \label{thm:universality_of_regex}
%    $k$-ESU can be determined for any acyclic automaton $\mathcal{A}$ containing $m$ transitions over an alphabet of size $\sigma$ in $O(m 2^{\sigma})$ time.
%\end{theorem}
%\ifpaper
%\else
%\input{proofs/proof_universality_of_rexexp}
%\fi
%
%

\begin{proof}
	We once more assume that $A$ has a single final state. We process $A$ as in Section \ref{sec:preProc} and obtain the strongly connected components of $G_A$, and the corresponding directed acyclic graph of strongly connected components $S(A)$. We now order the vertices of $S(A)$ topologically (using the standard topological sorting algorithm, which runs in $O(n+m)$ time). Note that ${\mathcal C}_{S(q_0)}$ is always the first strongly connected component in this topological sorting of $S(A)$ (as all states are accessible) and ${\mathcal C}_{S_f}=\{f\}$ is the last component in this sorting. 
	
	Let ${\mathcal C}_1={\mathcal C}_{S(q_0)},\ldots, {\mathcal C}_e=\{f\}$ be the strongly connected components of $A$, as ordered by the topological sorting. It is worth noting that in the directed acyclic graph of the strongly connected components of $A$, ${\mathcal C}_e$ is the only component that it is not the origin of any edge.
	
	Using Lemma \ref{lem:cycles}, we compute $V_i$, the set of labels of transitions of ${\mathcal C}_i$, for $i\in [e]$. For simplicity, if some $V_i$ contains $\epsilon$, then we remove it. Note that $\Sigma\setminus V_i\neq \emptyset$, as, otherwise, we would have words of arbitrarily large universality in $L$, and we have assumed that this is not the case. Similarly, for $j\in [e]$, we compute the set $V_{\rightarrow j}$ of pairs $(i,a)$ for which there exist transitions $(q_1,a, q_2)$ with $q_1\in {\mathcal C}_i$ and $q_2\in {\mathcal C}_j$. This can be done in $O(n+m)$ time as follows. We go through the transitions of $A$ and rename the transition $(q_1,a,q_2)$ as $(S(q_1),a,S(q_2)$. We sort (using radix sort) the list of renamed transitions $(S(q_1),a,S(q_2))$ of $A$, w.r.t. their third component (i.e., target), as first criterium, their first component (i.e., origin) as second criterium, and the second component (i.e., label) as third criterium (for this criterium we take the natural order on the integer alphabet $\Sigma$, and assume $\epsilon$ is smaller than all letters of $\Sigma$). Then, we eliminate duplicates. Finally, we go through the sorted list and if $(i,a,j)$ is the current element, then we add $(i,a)$ to $V_{\rightarrow j}$ 
	
	We now implement a dynamic programming approach. We define $e\times 2^\sigma$ matrix $D[\cdot][\cdot]$, where $D[i][S]$, for some $i\in [e]$ and $V_i \subseteq S\subsetneq \Sigma$, is the largest universality index of a word $w$ that labels a path which goes through the components ${\mathcal C}_1, \ldots, {\mathcal C}_i$, ending in ${\mathcal C}_i$, such that the rest $\al(\r(w))=S$. 
	
	We initialize $D[i][S]=-1$, for all $i\in [e]$ and $S\subsetneq \Sigma$.
	
	In step $1$, we set $D[1][V_1]=0$. 
	
	In step $i$, for $i\geq 2$, we compute the values $D[i][\cdot]$ by the following formula. If $(h,a)\in V_{\rightarrow j}$, we have $h<i$ due to the topological sorting; let $I_a=\{a\}$ if $a\neq \epsilon$ and $I_a=\emptyset$, otherwise. For each $S'\subsetneq \Sigma$, we proceed as follows. If $S'\cup\{a\}\cup V_i=\Sigma$ and $D[h][S']\neq -1$, then we set $D[i][V_i]=D[h][S']+1$. If $S'\cup\{a\}\cup V_i\neq \Sigma$ and $D[h][S']\neq -1$, we set $D[i][S'\cup\{a\}\cup V_i]=D[h][S']$. 
	
	The time needed in each step $i$ is upper bounded by $O(m_i 2^\sigma)$, where $m_i$ is the number of transitions whose target is in ${\mathcal C}_i$, so the overall time of computing the elements of the matrix $D$ is $O(m 2^\sigma)$.
	
	The largest value stored in the array $D[e][\cdot]$ is the largest universality of a word of $L$. To solve $k$-ESU, we simply need to check whether this value is greater than $k$. \looseness=-1
	
	The correctness of our approach is based on the following argument. We are interested in computing the words with the largest universality index that label paths which go through the components ${\mathcal C}_1, \ldots, {\mathcal C}_i$, and end in ${\mathcal C}_i$. For $i=1$, any such word $w$ has the rest $\r(w)\subseteq V_1$ and is not $1$-universal; obviously, it makes sense to always consider the words which have the largest rest w.r.t. inclusion. That is, we will consider only words which have $\r(w)=S$ (e.g.., which go at least once through all the transitions of ${\mathcal C}_1$); therefore we set $D[1][V_1]=0$. Clearly, $D[1][S]$ is undefined for all $S$ strictly containing $V_1$. Now, in step $i\leq 2$, let us assume the values $D[j][\cdot]$ are correctly computed for all $j<i$, and we want to compute the words with the largest universality index that label paths which go through the components ${\mathcal C}_1, \ldots, {\mathcal C}_i$, and end in ${\mathcal C}_i$. Let $w$ be such a word. We have that $w=w'aw''$, were $w'$ labels a path which goes through the components ${\mathcal C}_1, \ldots, {\mathcal C}_j$, for some $j$, $a$ is the label of a transition connecting component ${\mathcal C}_j$ with component ${\mathcal C}_i$, and then $w''$ is the label of a path going through $C_i$. If $\r(w')=S$, then we can assume that $w'$ is one of the words with the largest universality index that label paths which go through the components ${\mathcal C}_1, \ldots, {\mathcal C}_j$, ends in ${\mathcal C}_j$, and $\r(w')=S$ (i.e., its universality index is $D[j][S]$). Now, following the transition labelled with $a$ and those labelled with $w''$ we can achieve two things. On the one hand, if $V_i\cup\{b\}\cup S=\Sigma$, we can complete $\r(w' a)$ with the letters from $V_i$ (by choosing a prefix of $w''$ to be the label of a path that goes through all the transitions of ${\mathcal C}_i$) and create a new arch; then we can assume that $w''$ continues with the label of a path that goes through all the transitions of ${\mathcal C}_i$, and this creates a rest whose alphabet is $V_i$ (we could also assume $w''$ ends with a path with less letters, but this does not make sense when creating words with large universality index). To conclude, this suffix of $w''$ cannot create more arches nor a rest with a larger alphabet (w.r.t. inclusion); however, in total, $w''$ created one additional arch and the with alphabet equal to  $V_i$. On the other hand, if $V_i\cup\{b\}\cup S\neq \Sigma$, $w''$ can only contribute by adding the letters of $V_i$ to the alphabet of the rest of the constructed word (by choosing $w''$ to be the label of a path that goes through all the transitions of ${\mathcal C}_i$). These two cases are covered by the formula implemented by our dynamic programming approach. Clearly, when $i$ is considered we have to consider all choices of the component ${\mathcal C}_j$ from which we make the transition to ${\mathcal C}_i$. Based on these remarks, our approach is sound. 
	
	The statement follows.
	\qed\end{proof}
\medskip

\noindent \textbf{Regular Expressions.} 
We now consider languages represented by regexes. While NFAs and regexes define the same class of languages, the size of a regex required to represent a given language can be exponentially larger than the size of the NFA accepting that language (and vice versa, see, e.g., \cite{GruberH15}). % for a discussion on trade-offs between various representations of regular languages). 
In this section, we first show that $k$-ESU, where the language is specified as a regex of length $n$, can be solved in $O( n 2^{\sigma})$ time, using the FPT-algorithm w.r.t. $\sigma$ described above. Then, we provide a new proof of the NP-completeness of $k$-ESU when the input language is given as a regex. This result is interesting, as the hardness proof from \cite{regunivpaper} seems to require, in some cases, a regex exponentially larger than the corresponding NFA to describe the regular language used in the given reduction.  \looseness=-1

We start with the algorithmic part of this section. We assume from now on that we are given a regular expression of length $n$. The first result is immediate, by a proof similar to Lemma \ref{lem:infUniv}. 
\begin{lemma}
    \label{lem:unbounded_universality_regex}
    For regular expression $R$, if $R=R_1(R_2)^*R_3$ and $\Sigma\subseteq \al(R_2)$, then $L(R)$ is $k$-universal, for every $k\geq 1$. 
\end{lemma}
We can now decide in $O(n)$ time, for a regex $R$ of length $n$, whether $L(R)$ is $k$-universal, for every $k\geq 1$. If not, then $\iota(w)\leq n$ for all $w\in L(R)$, as $|w|\leq n$. In this case, we can reduce the case of general regexes to the case of star-free regexes.\looseness=-1

\begin{lemma}\label{lem:regex_acyclic}
    Given regular expression $R$, if there does not exist a decomposition $R = U_1(U_2)^*U_3$ with $\Sigma\subseteq \al(U_2)$, then there exist $k\geq 1$ such that $L(R)$ is not $k$-universal. Moreover, there exists a star-free regular expression $R'$, which can be computed in linear time $O(|R|)$, such that $\max\{\iota(w)\mid w\in L(R')\}= \max\{\iota(w)\mid w\in L(R)\}$.
\end{lemma}
\ifpaper
\else
\input{proofs/proof_regex_acyclic}
\fi

Lemma \ref{lem:regex_acyclic} immediately leads us to the following conclusion. 
\begin{theorem}\label{thm:FPT_sigma_regex}
Given a regular language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as a regex $R$ of length $n$, we can solve $k$-ESU in $O(n2^\sigma)$ time. 
\end{theorem}
\ifpaper
The idea is to first use Lemma \ref{lem:regex_acyclic} to construct a star-free regular expression $R'$, of size $O(n)$, such that $\max\{\iota(w)\mid w\in L(R')\}= \max\{\iota(w)\mid w\in L(R)\}$. Then we build an NFA for $R'$, of total size $O(n)$, and use Theorem \ref{thm:FPT_sigma} for this NFA.
\else
\input{proofs/proof_FPT_sigma_regex}
\fi

This result shows that $k$-ESU can be solved in linear time for regular expressions over constant-size alphabets.

Regarding the hardness of $k$-ESU when the input is given as a regular expression, we can show the following result. 
\begin{theorem}
    \label{thm:regex_is_hard}
    $k$-ESU is NP-complete for languages defined by regular expressions. The problem is already NP-hard for $k=1$ and star-free regexes. 
\end{theorem}
\ifpaper
This result follows from a reduction that maps $3$-SAT-instances with $n$ variables and $m$ clauses to $1$-ESU-instances where the input regex has length $O(m)$.
\else
\input{proofs/proof_regex_is_hard}
\fi


\medskip 

\noindent \textbf{Concluding Remarks.} The lower bound of Theorem \ref{thm:regex_is_hard} and its proof allow us to also make several final remarks on the presented FPT algorithms for $k$-ESU. We consider first the case when the input regular language is given as an NFA with $n$ states over an alphabet with $\sigma$ letters. The lower bound derived for $k$-ESU in~\cite{regunivpaper} and its proof show that, under the Exponential Time Hypothesis \cite{ImpagliazzoPZ01,LokshtanovMS11}, there are no $2^{o(\sigma)}\poly(n,\sigma)$ time algorithms solving the respective problem. The reduction from the proof of Theorem \ref{thm:regex_is_hard}, together with the Sparsification Lemma~\cite{ImpagliazzoPZ01}, shows that there are no $2^{o(n)}\poly(n,\sigma)$ time algorithms for $k$-ESU, under ETH. If the input language is given as a regular expression of length $n$ over an alphabet with $\sigma$ letters, we can once more refer to the reduction from the proof of Theorem \ref{thm:regex_is_hard} and the Sparsification Lemma, and get that there are no $2^{o(n)}\poly(n,\sigma)$ time algorithms for $k$-ESU, in this setting. As such, the algorithmic results we have obtained are tight from a fine-grained complexity perspective. \looseness=-1
\begin{proof}
	Let $R_0=R$. For $i\geq 0$ we rewrite $R_i$ into $R_{i+1}$ as follows. If $R_i=U_1(U_2)^*U_3$, such that $U_1$ is a valid star-free regex (i.e., there is open parenthesis which is not matched inside $U_1$), then we define $R_{i+1}=U_1u_2u_2U_3$, where $u_2=a_1\cdots a_t$ and $\{a_1,\ldots,a_t\}=\al(U_2)\cap\Sigma$. We claim that $\max\{\iota(w)\mid w\in L(R_{i+1})\}= \max\{\iota(w)\mid w\in L(R_{i})\}$. 
	
	Indeed, let $w$ be a word from $L(R_i)$ such that $\iota(w)$ is maximum. Then $w=w' w_1\cdots w_p w''$, such that $w'$ is described by $U_1$, $w''$ by $U_3$, and $w_1,\ldots,w_p$ are all described by $U_2$. Consider the arch factorisation of $w$: $w=\ar_1(w) \cdots \ar_k(w) \r(w)$. Because $\al(w_1\cdots w_p)\subsetneq \Sigma$, either $w_1\cdots w_p$ is completely contained in an arch $\ar_i(w)$, or there is an arch $\ar_i(w)$ covering a prefix of $w_1\cdots w_p$ and the remaining suffix of $w_1\ldots w_p$ is either covered by $\ar_{i+1}$ or by $\r(w)$. In both cases, we can immediately see that replacing in $w$ the factor $w_1\cdots w_p$ by $u_2u_2 $  can only produce a word $w'$ with $\iota(w')\geq \iota(w)$ (we need to insert two times the factor $u_2$ to account for the letters of the prefix of $w_1\cdots w_p$ covered by $\ar_i(w)$ and for the letters of its suffix covered by by $\ar_{i+1}$ or by $\r(w)$, in the second case mentioned above). 
	
	For the converse, let $w$ be a word from $L(R_{i+1})$ such that $\iota(w)$ is maximum. Then $w=w' u_2 u_2 w''$, such that $w'$ is described by $U_1$ and $w''$ by $U_3$. For each letter $a\in \Sigma $ appearing in $U_2$, there exists a word $w_a$ which is described by $U_2$; if $u_2=a_1\cdots a_t$, let $w_{U_2}=w_{a_1}\cdots w_{a_t}$ and note that $w_{U_2} \in L(U_2^*)$. Now, $u=w' w_{U_2} w_{U_2}w''$ has $w$ as a subsequence, so $\iota(u)\geq \iota(w)$. Moreover, $u\in L(R_i)$. Our claim has now be proven.
	
	Moreover, if $R_0=U_1(U_2)^*\cdots U_{2p-1}(U_{2p})^*U_{2p+1}$, such that $U_{2i-1}$ is a valid star-free regex for $i\in [p+1]$, then this process is finished after $p$ steps, and the resulting regex $R_{p}$ has length upper bounded by $O(|R|)$. 
	
	The statement holds for $R'=R_p$.
	\qed\end{proof}
\begin{proof}
	From $R$ we construct the star-free regex $R'$ as in Lemma \ref{lem:regex_acyclic}. This takes linear time $O(n)$, and $|R'|\in O(n)$. From the star-free regex $R'$ we can construct an acyclic NFA $A$ accepting $L(R')$ in $O(n)$ time (using the classical Thompson-construction, see, e.g., \cite{AllauzenM06}, and the references therein); $A$ has $O(n)$ states and $O(n)$ transitions. We can now apply Theorem \ref{thm:FPT_sigma} and get the result.
	\qed\end{proof}
\begin{proof}
The fact that $k$-ESU is in NP, irrespective of the value of $k$, follows from Lemmas \ref{lem:unbounded_universality_regex} and \ref{lem:regex_acyclic}. For a regular expression $R$, if there is no decomposition $R=U_1(U_2)^*U_3$ with $\Sigma\subseteq \al(U_2)$, then we construct a star-free regular expression $R'$, in linear time $O(|R|)$, such that $\max\{\iota(w)\mid w\in L(R')\}= \max\{\iota(w)\mid w\in L(R)\}$. Then we simply guess a word of length at most $|R'|$, check if this is generated by $R'$, and then check if its universality index is greater than $k$. 

For the hardness part, we present a reduction from $3$-SAT to $1$-ESU. Recall that the $3$-SAT problem takes a set of clauses $C_1, C_2, \dots, C_m$, each containing (at most) $3$ variables from the set $x_1, x_2, \dots, x_n$ of boolean variables. An instance of $3$-SAT is satisfiable if there exists some assignment to the set of variables such that every clause is true.

 Given an instance of $3$-SAT, we construct a regular expression $W$ as follows. We create the alphabet $\Sigma = \{c_1, c_2, \dots, c_m\}$ containing a unique symbol corresponding to each clause in the SAT instance. Given the variable $x_i$, let $C_{i,1}, C_{i, 2}, \dots, C_{i, j}$ be the clauses satisfied by a true assignment to $x_i$, and let $\overline{C}_{i,1}, \overline{C}_{i, 2}, \dots, \overline{C}_{i, j'}$ be the set of clauses satisfied by a false assignment to $x_i$. We construct, from $x_i$, the regular expression $V_i = (T_i \mid F_i)$, with  $T_i= c_{i, 1} c_{i, 2} \dots c_{i, j}$ and $F_i= \overline{c}_{i,1} \overline{c}_{i, 2} \dots \overline{c}_{i, j'}$, where $c_{i, \ell}$ is the symbol of $\Sigma$ corresponding to $C_{i, \ell}$, and $\overline{c}_{i, \ell'}$ the symbol of $\Sigma$ corresponding to $\overline{C}_{i, \ell'}$. We form the regular expression $W$ by concatenating $V_1, V_2, \dots, V_{n}$ into a single star-free regular expression, giving $W = V_1 V_2 \cdots V_n$. 
 
 Clearly, the length of the regular expression $W$ is $O(m)$, as each clause contains at most three variables; as side note, $W$ is star-free,  and there is an acyclic NFA of size $O(m)$ accepting $L(w)$. Moreover, the alphabet of $W$ has $m$ letters. 


	Let now $W$ be a regular expression constructed for some given $3$-SAT instance as above. First, let us assume that there is some $1$-universal word $w'$ represented by $W$, further let $w' = v'_1 v'_2 \cdots v'_n$ where $v'_i$ is the factor of $w'$ corresponding to the clause $V_i$ of $w$. We create an assignment for the $3$-SAT instance by setting $x_i$ to true, if $v_i' = T_i$, or false if $v_i' = F_i$. Note that, as $w'$ is 1-universal, the symbol $c_i$ must appear in $v_j'$ for some $j \in [n]$, and by extension, this assignment must satisfy $c_i$. Therefore, the assignment constructed in this way will satisfy the $3$-SAT instance. 
	
	In the other direction, given an assignment to the variables $x_1, x_2, \dots, x_n$ satisfying the $3$-SAT instance, we construct a word $w' = u_1 u_2 \dots u_n$ where $u_i$ is either $T_i$, if $x_i$ is true, or $F_i$ if $x_i$ is false. As every clause in the $3$-SAT instance is satisfied, there must be some $i \in [n]$ such that $c_j \in \letters(u_i)$ for every $j \in [m]$. Therefore, $\iota(w') \geq 1$, completing the proof. \qed
\end{proof}
%Within this section, we present the definitions of those subregular languages for which that NP-completeness follows immediately from known inclusion relations as depicted in Figure~\ref{fig:hierarchy}.
%Let $L$ be a language
%over an alphabet $\Sigma$. 
%With respect to the alphabet $\Sigma$, the language $L$ is said to be:
%\begin{itemize}
%	\item \emph{definite} ($\DEF$) iff $L=A\cup \Sigma^*B$
%	where~$A$ and~$B$ are finite subsets of $\Sigma^*$,
%	\item \emph{non-counting} ($\NC$) iff there is a natural
%	number $k\geq 1$ such that, for any three words $x\in \Sigma^*$, $y\in \Sigma^*$, and $z\in \Sigma^*$, it 
%	holds~$xy^kz\in L$ if and only if $xy^{k+1}z\in L$,
%	\item \emph{star-free} ($\SF$) iff $L$ can be described by a regular expression which is built by concatenation, union, and complementation,
%	\item \emph{power-separating ($\PS$)} iff, there is a natural number $m\geq 1$ such that
%	for any word~$x\in \Sigma^*$, either
%	$J_x^m \cap L = \emptyset$
%	or
%	$J_x^m\subseteq L$
%	where
%	$J_x^m = \{ x^n \mid n\geq m\}$,
%	\item \emph{union-free} ($\UF$) iff $L$ can be described by a regular expression which
%	is only built by product and star,
%	\item \emph{two-sided comet} ($\TCOM$) iff $L = EG^*H$ for some regular languages $E,H$ and $G$ with $G \notin \{\emptyset, \{\varepsilon\}\}$.
%\end{itemize}

A $2$-$\exists$-universal NFA ${A}$, which is not $3$-$\exists$-universal, and a $1$-$\forall$-universal NFA ${B}$ which is not $2$-$\forall$-universal are shown in Figure~\ref{img:universal_automaton}.

\input{figure}
%\todoah{setcounter correctly later, when content is setteled}
%\subsection{Proofs for Section~\ref{sec:FPT}}

%\setcounter[theorem]{2}

\noindent
\textbf{Lemma~\ref{lem:infUniv}.}
%\begin{lemma}%\label{} 
	$L$ contains, for each $i\in \N$, a word $w_i$ of universality $\iota(w_i)\geq i$ if and only if there exists a state $q$ of $A$ such that $\al(\labels(c_q))=\Sigma$. 
%\end{lemma}
\input{proofs/proof_infUniv}

\noindent
\textbf{Lemma~\ref{lem:cycles}.}
We can compute in $O(m+n)$ time the sets $V_i\subseteq \Sigma\cup \{\epsilon\}$ of all labels of transitions of the strongly connected component ${\mathcal C}_i$ of $A$, for $i\in [e]$. We can then access in $O(1)$ the set $V_{S(q)}$ with $\al(\labels(c_q))=V_{S(q)}$, for all $q\in Q$.
%\end{lemma}
\input{proofs/proof_cycles}

%\noindent
%\textbf{Lemma~\ref{lem:decomposition}.}
%	Let $w$ be a word with $\iota(w)=k$, which labels a walk \\
%	\centerline{$\beta=c^{i_1}_{q_1}p_{q_1,q'_1}(q'_1,b_2,q_2)c^{i_2}_{q_2}p_{q_2,q'_2}(q'_2,b_3,q_3)\cdots c^{i_{t-1}}_{q_{t-1}}p_{q_{t-1},q'_{t-1}}(q'_{t-1},b_t,q_t)c^{i_{t}}_{q_t}$,} 
%	where $q'_i$ is a state of ${\mathcal C}_{S(q_i)}$ for all $i\in [t]$, and $S(q_i)\neq S(q_j)$ for $i\neq j$. 
%	
%	Then, there exists a word $w'=w'_1\cdots w'_k$ and integers $s_0,s_1,\ldots,s_k$ such that:
%	\begin{itemize}[leftmargin=10pt,itemsep=1cm,parsep=-1cm]
%		\item $1=s_0<s_1<\ldots<s_k=t$
%		\item For $i\in [k]$, $w'_i$ is $1$-universal and labels the walk:\\
%		\hspace*{-10pt} $c_{q_{s_{i-1}}} p_{q_{s_{i-1}},q'_{s_{i-1}}}(q'_{s_{i-1}},b_{s_{i-1}+1},q_{s_{i-1}+1})\cdots c_{q_{s_i-1}}  p_{q_{s_i-1},q'_{s_i-1}} (q'_{s_i-1},b_{s_i},q_{s_i})c_{q_{s_i}}.$
%				\vspace*{-5pt}
%	\end{itemize}
%\input{proofs/proof_decomposition}

%\noindent
%\textbf{Lemma~\ref{lem:matching}.}
%	Given a sequence of $h<n$ states $q_1\cdots q_h$, such that $S(q_i)\neq S(q_j)$ for all $i\neq j$, we can decide in polynomial time $O(m+n\sigma \sqrt{n+\sigma})$ whether there exists a sequence of states $g_1\cdots g_h$, such that $S(g_i)=S(q_i)$ for all $i\in [h]$, and a walk 
%	$\beta = c_{q_1}p_{q_1,g'_1} (g'_1,b_2,g_2)\ldots c_{g_{h-1}}p_{g_{h-1},g'_{h-1}}(g'_{h-1},b_h,g_h)c_{g_h}p_{g_h,q_h}$ such that $\labels(\beta)$ is $1$-universal. 
%\input{proofs/proof_matching}

%\noindent
%\textbf{Theorem~\ref{thm:reducedwalkExpressions}.}
%	If $L$ contains a word $w$ with $\iota(w)=k$ then there exists a word $u\in L$ with $\iota(u)\geq k$, which is the label of a walk denoted by a walk expression of the form $(q_0[c_{q_0}]q_0',b_1,q_1)(q_1[c_{q_1}]q_1',b_2,q_2)\ldots (q_{h-1}[c_{q_{h-1}}]q'_{h-1},b_h,q_h)$, where: $h\leq n$; $q'_i$ belongs to ${\mathcal C}_{S(q_i)}$ for all $i\in [h-1]$; $S(q_i)\neq S(q_j)$, for all $i\neq j$; and $q_h=f$ is the final state of $A$. 
%\input{proofs/proof_reducedPathExpressions}

\noindent
\textbf{Lemma~\ref{lem:algo_one_seq}.}
	Given a sequence $q_1\cdots q_h$ of $h< n$ states with $q_h=f$ and $S(q_i)\neq S(q_j)$, for all $i\neq j$, we can compute in $O(n(m+ n\sigma \sqrt{n}))$ time the maximum integer $k$ for which there exists a walk $\beta$ with origin $q_1$ and target $q_h$ such that $\labels(\beta)$ is $k$-universal and $\beta$ goes through the strongly connected components of $q_1,\ldots,q_h$, and through no other strongly connected component. 
\input{proofs/proof_algo_one_seq}

\noindent
\textbf{Theorem~\ref{thm:FPT_states}.}
	Given a regular language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as an NFA $A$ with $n$ states, we can solve $k$-ESU in $O(2^nn(m+ n\sigma\sqrt{n}))$ time. That is, in the case when the input is given as an NFA, $k$-ESU is FPT w.r.t. the number $n$ of states of the input NFA.
\input{proofs/proof_FPT_states}

\noindent
\textbf{Theorem~\ref{thm:FPT_sigma}.}
	Given a regular language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as an NFA $A$ with $n$ states, we can solve $k$-ESU in $O(n + m + m2^\sigma)$ time. 
\input{proofs/proof_FPT_sigma}


\noindent
\textbf{Lemma~\ref{lem:regex_acyclic}.}
	For regular expression $R$, if there is no decomposition $R=U_1(U_2)^*U_3$ with $\Sigma\subseteq \al(U_2)$, then there exist $k\geq 1$ such that $L(R)$ is not $k$-universal. Moreover, there exists a star-free regular expression $R'$, which can be computed in linear time $O(|R|)$, such that $\max\{\iota(w)\mid w\in L(R')\}= \max\{\iota(w)\mid w\in L(R)\}$.
\input{proofs/proof_regex_acyclic}

\noindent
\textbf{Theorem~\ref{thm:FPT_sigma_regex}.}
	Given a regular language $L$, over $\Sigma$, with $|\Sigma|=\sigma$, specified as a regex $R$ of length $n$, we can solve $k$-ESU in $O(n2^\sigma)$ time. 
\input{proofs/proof_FPT_sigma_regex}

\noindent
\textbf{Theorem~\ref{thm:regex_is_hard}.}
	$k$-ESU is NP-complete for languages defined by regular expressions. The problem is already NP-hard for $k=1$. 
\input{proofs/proof_regex_is_hard}

%\begin{proposition}
%	Any automaton $\mathcal{A}$ accepting a finite language is \emph{acyclic}.
%\end{proposition}
%\input{proofs/proof_finite_language_is_acyclic}
%
%\begin{lemma}[Adapted from \cite{regunivpaper}]
%	The $1$-ESU problem is NP-Hard for acyclic languages.
%\end{lemma}
%\input{proofs/proof_k-ESU_acyclic}
%
%\begin{lemma}
%	\[
%	L[\ell, s] = \bigvee_{(q, x) \in P_{\ell}} \left( L[q, s \setminus \{ x \}]\right).
%	\]
%\end{lemma}
%\input{proofs/proof_construction_L_table}
%
%\begin{lemma}
%	\[
%	U[\ell, s] = \begin{cases}
%		\max_{(q, x) \in P_{\ell, s}} U[q, s \setminus x] & s \neq \emptyset\\
%		\max\left(\max_{(q, x) \in Q_{\ell, \Sigma}} \left(U[\ell, s \setminus x] + 1 \right),  \max_{(q, x) \in P_{\ell}} U[\ell, \emptyset]\right)& s = \emptyset
%	\end{cases}
%	\]
%	where $Q_{\ell, s} = \{(q, x) \in P_{\ell} \mid x \in s, L[q, s \setminus x] = \text{ True }\}$.
%\end{lemma}
%\input{proofs/proof_construction_U_table}
%
%\begin{theorem}
%	$k$-ESU can be determined for any acyclic automaton $\mathcal{A}$ containing $m$ transitions over an alphabet of size $\sigma$ in $O(m 2^{\sigma})$ time.
%\end{theorem}
%\input{proofs/proof_universality_of_rexexp}
%
%\subsection{Proofs for Section~\ref{sec:regex}}
%
%\begin{theorem}
%	$1$-ESU is NP-Hard for languages defined by regular expressions.
%\end{theorem}
%\input{proofs/proof_regex_is_hard}
%
%\begin{lemma}
%	A regular expression $R$ is $k$-ESU for every $k \in \mathbb{N}$ if and only if $R$ contains some subexpression $r$ of the form $(r[2, \vert r \vert - 2])^*$ where $\letters(r) = \Sigma$.
%\end{lemma}
%\input{proofs/proof_unbounded_universality_regex}
%
%\begin{theorem}
%	We can determine in $O(n)$ time if a regular expression $R$ containing $n$ symbols is $k$-ESU for every $k \in \mathbb{N}$.
%\end{theorem}
%\input{proofs/proof_regex_fixed_universality}
%
%\begin{lemma}
%%	\label{lem:making_expressions_star_free}
%	Let $R$ by a regular expression of the form $u_0 s_1 u_1 s_2 u_2 \dots u_{n - 1} s_n u_n$ where $u_0, u_1, \dots, u_n$ are star-free regular expressions, and $s_i = (s_i')^*$ where $s_i'$ is a regular expression, for every $i \in [n]$. Further, let $\letters(s_i) \neq \Sigma$, $\forall i \in [n]$. Then, $R$ is $k$-ESU if and only if $R' = u_0 t_1 u_1 t_2 u_2 \dots u_{n - 1} t_n u_n$ is, where $t_i = a_1 a_2 \dots a_{\alpha_i} a_1 a_2 \dots a_{\alpha_i}$ and $a_j$ is the $j^{th}$ symbol in $\letters(s_i')$ when $\letters(s_i')$ is ordered lexicographically.
%	% \todo{currently do not know how to fix it but since $\letters$ is a set, we cannot get the $j$th element, it is not ordered, maybe we can introduce another function that stores the letters in the order they are occurring}
%\end{lemma}
%\input{proofs/proof_making_expressions_star_free}
%
%\begin{theorem}
%%	\label{thm:regex_k_esu}
%	Given any regular expression $R$ containing $n$ symbols, we can determine, in $O(\sigma n 2^{\sigma})$ time, if $R$ is $k$-ESU for any $k \in \mathbb{N}$.
%\end{theorem}
%\input{proofs/proof_regex_k_esu}

%\subsection{Proofs for Section~\ref{sec:subregular}}
%
%\begin{lemma}%\label{lem:infUniv} 
%	$L$ contains, for each $i\in \N$, a word $w_i$ of universality $\iota(w_i)\geq i$ if and only if there exists a state $q$ of $A$ and a cycle $c_q$ in $A$ which contains $q$ and $\al(\labels(c_q))=\Sigma$. 
%\end{lemma}
%\input{proofs/proof_infUniv}
%
%\begin{lemma}%\label{lem:cycles} 
%	For each state $q$, we can determine in polynomial time $\poly(n,m)$ the largest set (w.r.t. set-inclusion) $V_q\subseteq \Sigma$ such that there exists a cycle $c_q$ in $A$, going through $q$, with $\al(\labels(c_q))=V_q$.
%\end{lemma}
%\ifpaper
%\else
%\input{proofs/proof_cycles}
%\fi
%
%\begin{theorem}%\label{thm:reducedPathExpressions}
%	If $L$ contains a word $w$ with $\iota(w)=k$ then there exists a word $u\in L$ with $\iota(u)\geq k$, which is the label of a path denoted by a path expression of the form $(q_0[c_{q_0}],b_1,q_1)(q_1[c_{q_1}],b_2,q_2)\ldots (q_{h-1}[c_{q_{h-1}}],b_h,q_h)$, where $h\leq n$ and $q_i\neq q_j$, for all $i\neq j$, and $q_h=f$ is the final state. 
%\end{theorem}
%\input{proofs/proof_reducedPathExpressions}
%
%\begin{lemma}%\label{lem:decomposition}
%	Let $w$ be a word with $\iota(w)=k$, which labels a path \\
%	\centerline{$\beta=c^{i_1}_{q_1}(q_1,,b_2,q_2)c^{i_2}_{q_2}(q_2,b_3,q_3)\cdots c^{i_{t-1}}_{q_{t-1}}(q_{t-1},b_t,q_t)c^{i_{t}}_{q_t}$.} 
%	Then there exists a word $w'=w'_1\ldots w'_k$ and integers $s_0,s_1,\ldots,s_k$ such that:
%	\begin{itemize}
%		\item $1=s_0<s_1<\ldots<s_k=t$
%		\item For $i\in [k]$, $w'_i$ is $1$-universal and labels the path:\\
%		$c_{q_{s_{i-1}}} (q_{s_{i-1}},b_{s_{i-1}+1},q_{s_{i-1}+1})\cdots c_{q_{s_i-1}} (q_{s_i-1},b_{s_i},q_{s_i-1})c_{q_{s_i}}.$
%	\end{itemize}
%\end{lemma}
%\input{proofs/proof_decomposition}
%
%\begin{lemma}%\label{lem:matching}
%	Given a sequence $q_1\cdots q_h$ of $h< n$ states, such that $q_i\neq q_j$ for all $i\neq j$, we can decide in polynomial time $\poly(\sigma,n)$ whether there exists a path $\beta=c_{q_1} (q_1,b_2,q_2)c_{q_2}(q_2,b_3,q_3)\ldots c_{q_{h-1}}(q_{h-1},b_h,q_h)c_{q_h}$ such that $\labels(\beta)$ is $1$-universal. 
%\end{lemma}
%\input{proofs/proof_matching}
%
%\begin{lemma}%\label{lem:algo_one_seq}
%	Given a sequence $q_1\cdots q_h$ of $h< n$ states and $q_h=f$, such that $q_i\neq q_j$, for all $i\neq j$, we can compute in polynomial time $\poly(\sigma,n)$ the maximum number $k$ for which there exists a path expression \\
%	\centerline{$\beta=(q_1[c_{q_1}],b_2,q_2)(q_2[c_{q_2}],b_3,q_3)\ldots (q_{h-1}[c_{q_{h-1}}],b_h,q_h)$} 
%	and a path $\beta'$ denoted by $\beta$ such that $\labels(\beta')$ is $k$-universal. 
%\end{lemma}
%\input{proofs/proof_algo_one_seq}
%
%\begin{theorem}%\label{thm:FPT_states}
%	Given a regular language $L$, over the alphabet $\Sigma$, with $|\Sigma|=\sigma$, specified as an NFA $A$ with $n$ states, we can solve $k$-ESU in $O(n! \poly(n\sigma))$. That is, in the case when the input is given as an NFA, $k$-ESU is FPT w.r.t. the number of states of the input NFA.
%\end{theorem}
%\input{proofs/proof_FPT_states}
%
%\begin{corollary}
%	$k$-ESU is NP-hard for $RL_n^P$ for all $n \in \N$.
%\end{corollary}
%\input{proofs/proof_k-ESU_RLNP}
%
%\begin{lemma}
%%	\label{prop:commutative_finite_k}
%	For a $k \in \N$ and a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, the $k$-ESU problem can be decided in $O(\min(\sigma k, n\sigma))$ time.
%\end{lemma}
%\input{proofs/proof_commutative_finite_k}
%
%\begin{lemma}
%%	\label{prop:commutative_infinite_k}
%	For a $k \in \N$ and a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, we can determine if there is a positive solution to the $k$-ESU problem for every $k \in \mathbb{N}$ in $O(n \sigma)$ time.
%\end{lemma}
%\input{proofs/proof_commutative_infinite_k}
%
%\begin{theorem}
%	For a commutative language $L$ represented by an $n$-state DFA $\mathcal{A}$, we can find the maximal $k$ such that $k$-ESU is fulfilled in $O(n \sigma \log n)$ time.
%\end{theorem}
%\input{proofs/proof_maximal_k_commutative_language}
\begin{thebibliography}{10}
\providecommand{\url}[1]{\texttt{#1}}
\providecommand{\urlprefix}{URL }
\providecommand{\doi}[1]{https://doi.org/#1}

\bibitem{AbboudEtAl2015}
Abboud, A., Backurs, A., Williams, V.V.: Tight hardness results for {LCS} and
  other sequence similarity measures. In: {IEEE} 56th Annual Symposium on
  Foundations of Computer Science, {FOCS} 2015, Berkeley, CA, USA, 17-20
  October, 2015. pp. 59--78 (2015). \doi{10.1109/FOCS.2015.14},
  \url{https://doi.org/10.1109/FOCS.2015.14}

\bibitem{AbboudRubinstein2018}
Abboud, A., Rubinstein, A.: Fast and deterministic constant factor
  approximation algorithms for {LCS} imply new circuit lower bounds. In: 9th
  Innovations in Theoretical Computer Science Conference, {ITCS} 2018, January
  11-14, 2018, Cambridge, MA, {USA}. pp. 35:1--35:14 (2018).
  \doi{10.4230/LIPIcs.ITCS.2018.35},
  \url{https://doi.org/10.4230/LIPIcs.ITCS.2018.35}

\bibitem{AbboudEtAl2014}
Abboud, A., Williams, V.V., Weimann, O.: Consequences of faster alignment of
  sequences. In: Automata, Languages, and Programming - 41st International
  Colloquium, {ICALP} 2014, Copenhagen, Denmark, July 8-11, 2014, Proceedings,
  Part {I}. pp. 39--51 (2014). \doi{10.1007/978-3-662-43948-7\_4},
  \url{https://doi.org/10.1007/978-3-662-43948-7\_4}

\bibitem{adamson2023words}
Adamson, D.: Ranking and unranking $k$-subsequence universal words. In: Frid,
  A., Merca{\c{s}}, R. (eds.) WORDS. pp. 47--59. Springer Nature Switzerland
  (2023)

\bibitem{regunivpaper}
Adamson, D., Fleischmann, P., Huch, A., Ko{\ss}, T., Manea, F., Nowotka, D.:
  k-universality of regular languages. In: {ISAAC} 2023. LIPIcs, vol.~283, pp.
  4:1--4:21. Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik (2023)

\bibitem{Goettingen2023words}
Adamson, D., Kosche, M., Ko{\ss}, T., Manea, F., Siemer, S.: Longest common
  subsequence with gap constraints. In: Frid, A., Merca{\c{s}}, R. (eds.)
  WORDS. pp. 60--76 (2023)

\bibitem{AllauzenM06}
Allauzen, C., Mohri, M.: A unified construction of the glushkov, follow, and
  antimirov automata. In: Kralovic, R., Urzyczyn, P. (eds.) Mathematical
  Foundations of Computer Science 2006, 31st International Symposium, {MFCS}
  2006, Star{\'{a}} Lesn{\'{a}}, Slovakia, August 28-September 1, 2006,
  Proceedings. Lecture Notes in Computer Science, vol.~4162, pp. 110--121.
  Springer (2006). \doi{10.1007/11821069\_10},
  \url{https://doi.org/10.1007/11821069\_10}

\bibitem{AnandZ23}
Anand, A., Zetzsche, G.: Priority downward closures. In: P{\'{e}}rez, G.A.,
  Raskin, J. (eds.) 34th International Conference on Concurrency Theory,
  {CONCUR} 2023, September 18-23, 2023, Antwerp, Belgium. LIPIcs, vol.~279, pp.
  39:1--39:18. Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik (2023).
  \doi{10.4230/LIPICS.CONCUR.2023.39},
  \url{https://doi.org/10.4230/LIPIcs.CONCUR.2023.39}

\bibitem{artikis2017complex}
Artikis, A., Margara, A., Ugarte, M., Vansummeren, S., Weidlich, M.: Complex
  event recognition languages: Tutorial. In: DEBS. pp. 7--10 (2017)

\bibitem{Baeza-Yates91}
Baeza{-}Yates, R.A.: Searching subsequences. Theoretical Computer Sciene
  \textbf{78}(2),  363--376 (1991)

\bibitem{barker2020scattered}
Barker, L., Fleischmann, P., Harwardt, K., Manea, F., Nowotka, D.: Scattered
  factor-universality of words. In: DLT. pp. 14--28. Springer (2020)

\bibitem{BergrothHR00}
Bergroth, L., Hakonen, H., Raita, T.: A survey of longest common subsequence
  algorithms. In: {SPIRE}. pp. 39--48. {IEEE} Computer Society (2000)

\bibitem{BringmannC18}
Bringmann, K., Chaudhury, B.R.: {Sketching, Streaming, and Fine-Grained
  Complexity of (Weighted) LCS}. In: Ganguly, S., Pandya, P. (eds.) 38th IARCS
  Annual Conference on Foundations of Software Technology and Theoretical
  Computer Science (FSTTCS 2018). LIPIcs, vol.~122, pp. 40:1--40:16 (2018).
  \doi{10.4230/LIPIcs.FSTTCS.2018.40}

\bibitem{BringmannK18}
Bringmann, K., K{\"{u}}nnemann, M.: Multivariate fine-grained complexity of
  longest common subsequence. In: Proc. {SODA} 2018. pp. 1216--1235 (2018)

\bibitem{chvatal1975longest}
Chvatal, V., Sankoff, D.: Longest common subsequences of two random sequences.
  Journal of Applied Probability  \textbf{12}(2),  306--315 (1975)

\bibitem{crochemore}
Crochemore, M., Hancart, C., Lecroq, T.: Algorithms on strings. Cambridge
  University Press (2007)

\bibitem{DBLP:journals/jda/CrochemoreMT03}
Crochemore, M., Melichar, B., Tron{\'{\i}}cek, Z.: Directed acyclic subsequence
  graph - overview. J. Discrete Algorithms  \textbf{1}(3-4),  255--280 (2003)

\bibitem{day2021edit}
Day, J., Fleischmann, P., Kosche, M., Ko{\ss}, T., Manea, F., Siemer, S.: The
  edit distance to k-subsequence universality. In: {STACS}. vol.~187, pp.
  25:1--25:19 (2021)

\bibitem{DayKMS22}
Day, J.D., Kosche, M., Manea, F., Schmid, M.L.: Subsequences with gap
  constraints: Complexity bounds for matching and analysis problems. In: Bae,
  S.W., Park, H. (eds.) 33rd International Symposium on Algorithms and
  Computation, {ISAAC} 2022, December 19-21, 2022, Seoul, Korea. LIPIcs,
  vol.~248, pp. 64:1--64:18. Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r
  Informatik (2022). \doi{10.4230/LIPICS.ISAAC.2022.64},
  \url{https://doi.org/10.4230/LIPIcs.ISAAC.2022.64}

\bibitem{fazekas2024subsequencematchinganalysisproblems}
Fazekas, S.Z., Koß, T., Manea, F., Mercaş, R., Specht, T.: Subsequence
  matching and analysis problems for formal languages (2024),
  \url{https://arxiv.org/abs/2410.07992}

\bibitem{fleischer2018testing}
Fleischer, L., Kufleitner, M.: Testing simon's congruence. In: MFCS. Schloss
  Dagstuhl-Leibniz-Zentrum fuer Informatik (2018)

\bibitem{fleischmann2021scattered}
Fleischmann, P., Germann, S., Nowotka, D.: Scattered factor universality--the
  power of the remainder. preprint arXiv:2104.09063 (published at RuFiDim)
  (2021)

\bibitem{fleischmann2023alphabetafactorization}
Fleischmann, P., H{\"{o}}fer, J., Huch, A., Nowotka, D.:
  {\(\alpha\)}-{\(\beta\)}-factorization and the binary case of simon's
  congruence. In: {FCT}. LNCS, vol. 14292, pp. 190--204. Springer (2023)

\bibitem{DBLP:conf/rp/FleischmannKKMNSW23}
Fleischmann, P., Kim, S., Ko{\ss}, T., Manea, F., Nowotka, D., Siemer, S.,
  Wiedenh{\"{o}}ft, M.: Matching patterns with variables under simon's
  congruence. In: {RP} 2023. LNCS, vol. 14235, pp. 155--170. Springer (2023)

\bibitem{FredmanW90}
Fredman, M.L., Willard, D.E.: {BLASTING} through the information theoretic
  barrier with {FUSION} {TREES}. In: Ortiz, H. (ed.) Proceedings of the 22nd
  Annual {ACM} Symposium on Theory of Computing, May 13-17, 1990, Baltimore,
  Maryland, {USA}. pp.~1--7. {ACM} (1990). \doi{10.1145/100216.100217},
  \url{https://doi.org/10.1145/100216.100217}

\bibitem{FrochauxK23}
Frochaux, A., Kleest{-}Mei{\ss}ner, S.: Puzzling over subsequence-query
  extensions: Disjunction and generalised gaps. In: {AMW} 2023. {CEUR} Workshop
  Proceedings, vol.~3409. CEUR-WS.org (2023)

\bibitem{gawrychowski2021simons}
Gawrychowski, P., Kosche, M., Ko{\ss}, T., Manea, F., Siemer, S.: {Efficiently
  Testing Simon’s Congruence}. In: STACS. vol.~187, pp. 34:1--34:18 (2021)

\bibitem{GruberH15}
Gruber, H., Holzer, M.: From finite automata to regular expressions and back -
  {A} summary on descriptional complexity. Int. J. Found. Comput. Sci.
  \textbf{26}(8),  1009--1040 (2015). \doi{10.1142/S0129054115400110},
  \url{https://doi.org/10.1142/S0129054115400110}

\bibitem{halfon2017decidability}
Halfon, S., Schnoebelen, P., Zetzsche, G.: Decidability, complexity, and
  expressiveness of first-order logic over the subword ordering. In: LICS. pp.
  1--12. IEEE (2017)

\bibitem{han2020novel}
Han, R., Wang, S., Gao, X.: Novel algorithms for efficient subsequence
  searching and mapping in nanopore raw signals towards targeted sequencing.
  Bioinformatics  \textbf{36}(5),  1333--1343 (2020)

\bibitem{hebrard1991algorithm}
Hebrard, J.J.: An algorithm for distinguishing efficiently bit-strings by their
  subsequences. TCS  \textbf{82}(1),  35--49 (1991)

\bibitem{higman1952ordering}
Higman, G.: Ordering by divisibility in abstract algebras. Proceedings of the
  London Mathematical Society  \textbf{3}(1),  326--336 (1952)

\bibitem{Hirschberg77}
Hirschberg, D.S.: Algorithms for the longest common subsequence problem. J.
  {ACM}  \textbf{24}(4),  664--675 (1977)

\bibitem{HopcroftU79}
Hopcroft, J.E., Ullman, J.D.: Introduction to Automata Theory, Languages and
  Computation. Addison-Wesley (1979)

\bibitem{HopcroftK73}
Hopcroft, J.E., Karp, R.M.: An n\({}^{\mbox{5/2}}\) algorithm for maximum
  matchings in bipartite graphs. {SIAM} J. Comput.  \textbf{2}(4),  225--231
  (1973). \doi{10.1137/0202019}, \url{https://doi.org/10.1137/0202019}

\bibitem{HuntS77}
Hunt, J.W., Szymanski, T.G.: A fast algorithm for computing longest
  subsequences. Commun. {ACM}  \textbf{20}(5),  350--353 (1977)

\bibitem{ImpagliazzoPZ01}
Impagliazzo, R., Paturi, R., Zane, F.: Which problems have strongly exponential
  complexity? J. Comput. Syst. Sci.  \textbf{63}(4),  512--530 (2001).
  \doi{10.1006/JCSS.2001.1774}, \url{https://doi.org/10.1006/jcss.2001.1774}

\bibitem{KarandikarKS15}
Karandikar, P., Kufleitner, M., Schnoebelen, P.: On the index of {S}imon's
  congruence for piecewise testability. Inf. Process. Lett.  \textbf{115}(4),
  515--519 (2015)

\bibitem{karandikar2016height}
Karandikar, P., Schnoebelen, P.: The height of piecewise-testable languages
  with applications in logical complexity. In: CSL (2016)

\bibitem{KimKH22}
Kim, S., Ko, S., Han, Y.: Simon's congruence pattern matching. In: {ISAAC}.
  LIPIcs, vol.~248, pp. 60:1--60:17. Schloss Dagstuhl - Leibniz-Zentrum
  f{\"{u}}r Informatik (2022)

\bibitem{Kleest-Meissner22}
Kleest{-}Mei{\ss}ner, S., Sattler, R., Schmid, M.L., Schweikardt, N., Weidlich,
  M.: Discovering event queries from traces: Laying foundations for
  subsequence-queries with wildcards and gap-size constraints. In: {ICDT}.
  LIPIcs, vol.~220, pp. 18:1--18:21 (2022)

\bibitem{Kleest-Meissner23}
Kleest{-}Mei{\ss}ner, S., Sattler, R., Schmid, M.L., Schweikardt, N., Weidlich,
  M.: Discovering multi-dimensional subsequence queries from traces - from
  theory to practice. In: {BTW}. {LNI}, vol. {P-331}, pp. 511--533 (2023)

\bibitem{kosche2021absent}
Kosche, M., Ko{\ss}, T., Manea, F., Siemer, S.: Absent subsequences in words.
  In: RP. pp. 115--131. Springer (2021)

\bibitem{Kosche2022SubsequenceSurvey}
Kosche, M., Ko{\ss}, T., Manea, F., Siemer, S.: Combinatorial algorithms for
  subsequence matching: A survey. In: Bordihn, H., Horv\'ath, G., Vaszil, G.
  (eds.) NCMA (2022)

\bibitem{KoscheKMP22}
Kosche, M., Ko{\ss}, T., Manea, F., Pak, V.: Subsequences in bounded ranges:
  Matching and analysis problems. In: Lin, A.W., Zetzsche, G., Potapov, I.
  (eds.) Reachability Problems - 16th International Conference, {RP} 2022,
  Kaiserslautern, Germany, October 17-21, 2022, Proceedings. Lecture Notes in
  Computer Science, vol. 13608, pp. 140--159. Springer (2022).
  \doi{10.1007/978-3-031-19135-0\_10},
  \url{https://doi.org/10.1007/978-3-031-19135-0\_10}

\bibitem{DBLP:conf/csr/Kuske20}
Kuske, D.: The subtrace order and counting first-order logic. In: {CSR}. LNCS,
  vol. 12159, pp. 289--302. Springer (2020)

\bibitem{DBLP:conf/fossacs/KuskeZ19}
Kuske, D., Zetzsche, G.: Languages ordered by the subword order. In: {FOSSACS}.
  LNCS, vol. 11425, pp. 348--364. Springer (2019)

\bibitem{LokshtanovMS11}
Lokshtanov, D., Marx, D., Saurabh, S.: Lower bounds based on the exponential
  time hypothesis. Bull. {EATCS}  \textbf{105},  41--72 (2011),
  \url{http://eatcs.org/beatcs/index.php/beatcs/article/view/92}

\bibitem{Maier78}
Maier, D.: The complexity of some problems on subsequences and supersequences.
  J. {ACM}  \textbf{25}(2),  322--336 (1978)

\bibitem{ManeaRS24}
Manea, F., Richardsen, J., Schmid, M.L.: Subsequences with generalised gap
  constraints: Upper and lower complexity bounds. In: Inenaga, S., Puglisi,
  S.J. (eds.) 35th Annual Symposium on Combinatorial Pattern Matching, {CPM}
  2024, June 25-27, 2024, Fukuoka, Japan. LIPIcs, vol.~296, pp. 22:1--22:17.
  Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik (2024).
  \doi{10.4230/LIPICS.CPM.2024.22},
  \url{https://doi.org/10.4230/LIPIcs.CPM.2024.22}

\bibitem{MasekP80}
Masek, W.J., Paterson, M.: A faster algorithm computing string edit distances.
  Journal of Computer and System Sciences  \textbf{20}(1),  18--31 (1980).
  \doi{10.1016/0022-0000(80)90002-1},
  \url{https://doi.org/10.1016/0022-0000(80)90002-1}

\bibitem{NakatsuKY82}
Nakatsu, N., Kambayashi, Y., Yajima, S.: A longest common subsequence algorithm
  suitable for similar text strings. Acta Informatica  \textbf{18},  171--179
  (1982)

\bibitem{schnoebelen2019height}
Schnoebelen, P., Karandikar, P.: The height of piecewise-testable languages and
  the complexity of the logic of subwords. Logical Methods in Computer Science
  \textbf{15} (2019)

\bibitem{SchnoebelenV23}
Schnoebelen, P., Veron, J.: On arch factorization and subword universality for
  words and compressed words. In: {WORDS}. LNCS, vol. 13899, pp. 274--287.
  Springer (2023)

\bibitem{shaw1978software}
Shaw, A.C.: Software descriptions with flow expressions. IEEE Transactions on
  Software Engineering  \textbf{3},  242--254 (1978)

\bibitem{shikder2019openmp}
Shikder, R., Thulasiraman, P., Irani, P., Hu, P.: An openmp-based tool for
  finding longest common subsequence in bioinformatics. BMC research notes
  \textbf{12}, ~1--6 (2019)

\bibitem{simon1972thesis}
Simon, I.: Hierarchies of Events with Dot-depth One. Ph.D. thesis, University
  of Waterloo, Department of Applied Analysis and Computer Science (1972)

\bibitem{Simon72}
Simon, I.: Piecewise testable events. In: Autom.\ Theor.\ Form.\ Lang., 2nd GI
  Conf. LNCS, vol.~33, pp. 214--222. Springer (1975)

\bibitem{simon2003words}
Simon, I.: Words distinguished by their subwords. WORDS  \textbf{27},  6--13
  (2003)

\bibitem{Tarjan72}
Tarjan, R.E.: Depth-first search and linear graph algorithms. {SIAM} J. Comput.
   \textbf{1}(2),  146--160 (1972). \doi{10.1137/0201010},
  \url{https://doi.org/10.1137/0201010}

\bibitem{tronicek2003common}
Troni{\^c}ek, Z.: Common subsequence automaton. In: CIAA. pp. 270--275 (2003)

\bibitem{zetzsche2016complexity}
Zetzsche, G.: The complexity of downward closure comparisons. In: ICALP.
  vol.~55, pp. 123:1--123:14 (2016)

\bibitem{DBLP:conf/lics/Zetzsche18}
Zetzsche, G.: Separability by piecewise testable languages and downward
  closures beyond subwords. In: {LICS} 2018. pp. 929--938. {ACM} (2018)

\end{thebibliography}