1 Introduction

Parameterized complexity and algorithmics has been developing for more than twenty years. Some important progress of the field has depended on what Niedermeier has called “the art of problem parameterization” (see Chap. 5 of his monograph [23]). For example, it was Cristina Bazgan who first suggested that the parameter might be k=1/ϵ in the study of the complexity of approximation, leading eventually to the study of EPTASs [3].

Here we explore, for the first time (to our knowledge), a parameterization that seems widely relevant: the number of numbers. Many problems take as input information that consists (in part) of multisets of integers or multisets of weighted objects, such as weighted edges in a weighted graph, the time-requirements of jobs to be scheduled, or the sequence of molecular weights of a spectrographic dataset. Our investigations are of importance for problem input distributions where the number of distinct numerical values is small compared to the overall input size, and when the modeling of the problem allows rounding as a way to get to fewer distinct values.

In classical complexity, this “parameterization” has been explored in distribution-sensitive algorithmics [29]. For example, while Ω(nlogn) is a lower bound on sorting n values in the comparison model [18], a multiset of cardinality n and h distinct values can be sorted using O(nlogh) comparisons [22].

It is perhaps surprising that this parameterization in the sense of Niedermeier’s “art of problem parameterization” [23, 24] has not been considered before in parameterized complexity, as it seems entirely well-motivated. While weighted combinatorial optimization problems have generally strong claims to model realism, it is often the case that, e.g., the jobs to be scheduled may be of certain standard sizes arising in a limited number of ways, or that the costs of the nodes in a network problem may depend on the model and vendor of the device, of which there are a limited number of possibilities. Many similar scenarios easily come to mind. A bounded number of numbers may also arise naturally and implicitly in parameterized problems when numbers are associated to other parameterized aspects of a problem, such as alphabet size.

As an initial foray, we first show that a number of classic NP-hard problems about multisets of integers, when parameterized in this way, become fixed-parameter tractable. The proofs are easy, and the knowledgeable reader might anticipate them almost as exercises today—they use the relatively deep result that Integer Linear Programming, parameterized by the number of variables, is FPT. Until recently, as noted in the 2006 monograph by Niedermeier [23], there were not so many interesting applications of this fundamental result (see [1, 11, 12, 16] for some exceptions).

At a deeper level of engagement with this parameterization, we describe some examples of how number-of-numbers parameterized problems reduce to numerical problems about Mealy machines, parameterized by the size of the description of the machine. We show that one basic problem about Mealy machines, parameterized in this way, is FPT, and that another is W[1]-hard.

2 Preliminaries

Integer Linear Programming

In the Integer Linear Programming Feasibility problem (ILPF), the input is an m×n matrix A of integers and an m-vector b of integers, the parameter is n, and the question is whether there exists an n-vector x of integers satisfying the m inequalities Axb. ILPF, parameterized by the number of variables, was shown to be fixed-parameter tractable by Lenstra [20] and the running time has been improved by Kannan [17] and by Frank and Tardos [14].

Multisets

Let A be a multiset. The cardinality of A, denoted |A|, is the total number of elements in A, including repeated memberships. The variety of A, denoted ∥A∥, is the number of distinct elements in A. Element a has multiplicity m in A if it occurs m times in A. We denote the set of integers from 1 to n by [n]={1,…,n}.

Graphs

Let G=(V,E) be a graph, vV be a vertex of G, and SV be a subset of vertices of G. The subgraph of G induced on S is the graph G[S]=(S,E∩{uv:u,vS}). The set S is a clique of G if G[S] is complete, i.e. there is an edge between every two distinct vertices of G[S]. The set S is an independent set of G if G[S] is empty, i.e. G[S] has no edge. The neighborhood of v is the set of vertices incident to v and denoted N(v). The degree of v is d(v)=|N(v)|. We also define N S (v)=N(v)∩S and d S (v)=|N S (v)|.

Words

Let Σ be an alphabet. The elements of Σ are called letters, and a word x of length n=|x| is a sequence of n letters. The symbol ϵ denotes the empty letter. We denote the concatenation of two words x 1,x 2Σ by x 1 x 2. The ith power of a word x is denoted x i or (x)i and represents the word \(\underbrace{x x \dots x}_{i\text{ times}}\).

Parameterized Complexity

We define the basic notions of Parameterized Complexity and refer to other sources [6, 13, 23] for an in-depth treatment. A parameterized problem is a set of pairs (I,k), the instances, where I is the main part and k is the parameter. A parameterized problem is fixed-parameter tractable if there exist a computable function f and an algorithm that solves any instance (I,k) of size n in time f(k)n O(1). FPT denotes the class of all fixed-parameter tractable parameterized decision problems.

Parameterized complexity offers a completeness theory that allows the accumulation of strong theoretical evidence that some parameterized problems are not fixed-parameter tractable. This theory is based on a hierarchy of complexity classes

$$\text {FPT}\subseteq \text {W}[1] \subseteq \text {W}[2] \subseteq \text {W}[3] \subseteq\cdots \subseteq \text {XP},$$

where all inclusions are believed to be strict. Each class W[i] contains all parameterized decision problems that can be reduced to a canonical parameterized satisfiability problem P i under parameterized reductions. These are many-to-one reductions where the parameter for one problem maps into the parameter for the other. More specifically, a parameterized problem L reduces to a parameterized problem L′ if there is a mapping R from instances of L to instances of L′ such that

  1. 1.

    (I,k) is a Yes-instance of L if and only if (I′,k′)=R(I,k) is a Yes-instance of L′,

  2. 2.

    there is a computable function g such that k′≤g(k), and

  3. 3.

    there is a computable function f such that R can be computed in time f(k)⋅n O(1), where n denotes the size of (I,k).

A parameterized problem L is then in W[i], for i∈ℕ, if it has a parameterized reduction to the problem of deciding whether a Boolean decision circuit (a decision circuit is a circuit with exactly one output), with AND, OR, and NOT gates, of constant depth such that on each path from an input to the output, all but i gates have a constant number of inputs, parameterized by the number of ones in a satisfying assignment to the inputs of the circuit [6].

A parameterized problem is in XP if there exist computable functions f and g and an algorithm that solves any instance (I,k) of size n in time f(k)n g(k).

3 Subset Sum and Partition

We start with two classic problems on multisets and show that they are fixed-parameter tractable, parameterized by the number of numbers.

figure a
figure b

The parameterizon of Subset Sum by |X| is W[1]-hard [9]. This hardness also holds for the parameterization of Partition by |X| as an easy reduction from Subset Sum adds the integer (∑ aA a)−2s to A if s≤(∑ aA a)/2, and if s>(∑ aA a)/2, the reduction looks instead for the complement set AX that sums to (∑ aA a)−s and uses the previous construction.

Our FPT results use a deep result of Lenstra, stating that Integer Linear Programming Feasibility (ILPF), parameterized by the number of variables, is FPT. They are obtained by very natural formulations of the respective problems as integer programs.

Theorem 1

var-SubSum is fixed-parameter tractable.

Proof

Given an instance (A,s) for var-SubSum, with ∥A∥=k, we create an equivalent instance of ILPF whose number of variables is upper bounded by a function of k. Let a 1,…,a k denote the distinct elements of A and let m 1,…,m k denote their respective multiplicities in A. The ILPF instance has the integer variables x 1,…,x k and the following inequalities and equalities.

For each i∈[k], the variable x i represents the number of times a i occurs in X, the set summing to s in a valid solution. Using standard techniques in mathematical programming, these constraints can be transformed into the form Axb. □

A very similar proof shows that var-Part is fixed-parameter tractable.

Theorem 2

var-Part is fixed-parameter tractable.

Proof

Given an instance A for var-Part, with ∥A∥=k, we create an equivalent instance of ILPF whose number n of variables is upper bounded by a function of k.

Let a 1,…,a k denote the distinct elements of A and let m 1,…,m k denote their respective multiplicities in A. The ILPF instance has the integer variables x 1,…,x k and the following inequalities and equalities.

For each i∈[k], the variable x i represents the number of times a i occurs in X, such that ∑ aX a=∑ bAX b=∑ aA a/2 in a valid solution.

Using standard techniques in mathematical programming, these constraints can be transformed such that they respect the form Axb. □

4 Other Classic Numerical Problems

Using the ILPF machinery, we show in this section that several other problems, which are often used in NP-hardness proofs, become fixed-parameter tractable when parameterized by the number of numbers.

figure c

Theorem 3

var-Num3-DM is fixed-parameter tractable.

Proof

Let (A,B,C,s) be an instance for var-Num3-DM, with k 1=∥A∥, k 2=∥B∥, k 3=∥C∥, and k=∥ABC∥. Let \(a_{1}, \ldots, a_{k_{1}}\) denote the distinct elements of A, \(b_{1},\ldots, b_{k_{2}}\) denote the distinct elements of B, and \(c_{1}, \ldots,c_{k_{3}}\) denote the distinct elements of C. Also, let \(m_{1,a}, \ldots , m_{k_{1},a}, m_{1,b}, \ldots, m_{k_{2},b}, m_{1,c}, \ldots, m_{k_{3},c}\) denote their respective multiplicities in A, B, and C. We create an instance of ILPF with at most k 3 integer variables x i,j, , for i∈[k 1],j∈[k 2],∈[k 3]:

A variable x i,j, represents the number of times the elements a i A, b j B and c C are used together to form a triple summing to s. The first constraint makes sure that such a triple is formed only if it sums to s. The remaining equalities make sure that each element of ABC appears in a triple. Thus n such triples are formed, all summing to s if the integer program is feasible. □

Note that the problem is also fixed-parameter tractable if parameterized by ∥AB∥ only: we face a No-instance if ∥C∥>∥{a+b:aA,bB}∥. A closely related, well known numerical problem, is the following.

figure d

Corollary 1

var-NMTS is fixed-parameter tractable.

By the previous discussion, the natural parameterization by ∥AB∥ is also fixed-parameter tractable. A straightforward adaptation of the proof of Theorem 3 shows that variety-3-Partition is fixed-parameter tractable.

figure e

Theorem 4

var-3-Part is fixed-parameter tractable.

Proof

Let A be an instance for var-3-Part, with ∥A∥=k and |A|=3n. Let s=∑ aA a/n. Let a 1,…,a k denote the distinct elements of A and let m 1,…,m k denote their multiplicities in A. We create an instance of ILPF with at most k 3 integer variables x i,j, , for i,j,∈[k]:

A variable x i,j, represents the number of times the elements a i ,a j and a are used together to form a triple summing to s. The first constraint makes sure that such a triple is formed only if it sums to s. The second set of equalities make sure that each element of A appears in a triple. Thus n such triples are formed, all summing to s if the integer program is feasible. □

5 Mealy Machines

In this section, we explore how far we can generalize the rather simple FPT results of the previous two sections. To this end, we investigate the parameterized complexity of two problems about Mealy Machines. Both problems can be viewed as parameterized problems implicitly parameterized by the number of numbers, because in each case the size of the alphabet is part of the parameterization, and each letter of the alphabet is associated with a census requirement. The richer structure of these problems means that a simple appeal to integer linear programming no longer suffices: one turns out to be FPT, and the other W[1]-hard. In Sect. 6, we show that other problems parameterized by the number of numbers reduce to these two seemingly general problems of this kind.

Mealy machines [21] are finite-state transducers, generating an output based on their current state and input. They have important applications in cryptanalysis [2], computational linguistics [27], and control and system theory [30]. A deterministic Mealy machine is a dual-alphabet state transition system given by a 5-tuple M=(S,s 0,Γ,Σ,T):

  • a finite set of states S,

  • a start state s 0S,

  • a finite set Γ, called the input alphabet,

  • a finite set Σ, called the output alphabet, and

  • a transition function T:S×ΓS×Σ mapping pairs of a state and an input letter to the corresponding next state and output letter.

The alphabets Γ and Σ may contain the empty letter ϵ, as in [28]. This eases some of the description, but all our results also hold if we restrict ϵΓΣ.

In a non-deterministic Mealy machine, the only difference is that the transition function is defined \(T: S \times \varGamma \rightarrow\mathcal {P}(S \times \varSigma )\) as for a given state and input letter, there may be more than one possibility for the next state and output letter. (Here \(\mathcal{P}(X)\) denotes the powerset of a set X.)

A census requirement c:Σ∖{ϵ}→ℕ is a function assigning a non-negative integer to each letter of the output alphabet (except ϵ). It is used to constrain how many times each letter should appear in the output of a Mealy machine. A word xΣ meets the census requirement if every letter bΣ∖{ϵ} appears exactly c(b) times in x.

The notion of census requirement is related to Parikh images [25]. Let Σ∖{ϵ}={b 1,…,b σ }. For xΣ , the Parikh image is Ψ(x)=(c(b 1),…,c(b σ )), where c is the census requirement such that x meets c. The Parikh image of a language L is Ψ(L)={Ψ(x):xL}. Parikh’s theorem [25] states that the Parikh image of a context-free language is semilinear, i.e., that for every context-free language there is a regular language with the same Parikh image.

Our first problem about Mealy machines asks whether there exists an input word and a computation of the Mealy machine such that the output word meets the census requirement.

figure f

Our proof that var-EWMM is fixed-parameter tractable is inspired by the proof from [10] showing that Bandwidth is fixed-parameter tractable when parameterized by the maximum number of leaves in a spanning tree of the input graph. We need the following definition and lemma from [10].

In a digraph D, two directed walks Δ and Δ′ from a vertex s to a vertex t are arc-equivalent, if for every arc a of D, Δ and Δ′ pass through a the same number of times.

Lemma 1

[10]

Any directed walk Δ through a finite digraph D on n vertices from a vertex s to a vertex t of D is arc-equivalent to a directed walk Δfrom s to t, where Δhas the form:

  1. (1)

    Δconsists of an underlying directed walk ρ from s to t of length at most n 2,

  2. (2)

    together with some number of short loops, where each such short loop l begins and ends at a vertex of ρ, and has length at most n.

The algorithm will first subdivide state transitions in order to make the underlying directed graph simple. As suggested by Lemma 1, the algorithm goes over all possible choices for selecting an underlying directed walk ρ starting from s 0. For every short loop starting and ending at a vertex from ρ, the algorithm associates an integer variable representing the number of times this short loop is executed while moving along ρ. Again by Integer Linear Programming Feasibility, it can be checked whether there is a set of integers, representing the number of executions of the short loops, such that the number of times each output letter is written is compatible with the census requirement.

Theorem 5

var-EWMM is fixed-parameter tractable.

Proof

Let \((M'=(S',s_{0}',\varGamma ',\varSigma ',T'),c)\) be an instance for var-EWMM with k=|S′|+|Γ′|+|Σ′|. As M′ might have multiple transitions from one state to another, we first subdivide each transition in order to obtain a simple digraph underlying the Mealy machine (so we can use Lemma 1): create a new non-deterministic Mealy machine M=(S,s 0,Γ,Σ,T) such that, initially, S=S′, \(s_{0}=s_{0}'\), Γ=Γ′∪{ϵ}, and Σ=Σ′∪{ϵ}; for each transition t of T′ from a couple (s i ,〈i〉) to a couple (s o ,〈o〉), add a new state s t to S and add the transition from (s i ,〈i〉) to (s t ,〈o〉) and the transition from (s t ,ϵ) to (s o ,ϵ) to T. Clearly, there is at most one transition between every two states in M.

Our algorithm goes over all transition walks in M of length at most |S|2 that start from s 0. There are at most \(|S|^{(|S|^{2})}\) such transition walks and each such transition walk has at most |S||S| short loops, as they have length at most |S| by Lemma 1. Let P=(s 0,s 1,…,s |P|) be such a transition walk and L=( 1, 2,…, |L|) be its short loops. It remains to check whether there exists a set of integers X={x 1,x 2,…,x |L|} such that a word output by a computation of M moving from s 0 to s |P| along the walk P, and executing x i times each short loop i , 1≤i≤|L|, meets the census requirement. Note that if one such word meets the census requirement, then all such words meet the census requirement, as it does not matter in which order the short loops are executed. We verify whether such a set X exists by ILPF.

Let Σ∖{ϵ}={〈,1〉,〈,2〉,…,〈,σ〉}. Define m(i,j), for 1≤i≤|L|, 1≤jσ, to denote the number of times that M writes the letter 〈,j〉 when it executes the loop i once. Define m(j), for 1≤jσ, to be the number of times that M writes the letter 〈,j〉 when it transitions from s 0 to s |P| along the walk P. Then, we only need to verify that there exist integers x 1,x 2,…,x |L| such that

By construction, |S|≤|S′|+|T′|≤|S′|+|S′|2⋅|Γ′|⋅|Σ′|≤k+k 4. As the number of integer variables of this program is at most \(|L| \le |S|^{|S|} \le(k+k^{4})^{k+k^{4}}\), and the number of transition walks that the algorithm considers is at most \(|S|^{(|S|^{2})} \le (k+k^{4})^{k^{2}+2k^{5}+k^{8}}\), var-EWMM is fixed-parameter tractable. □

We note that the proof in [10] concerned a special case of a deterministic Mealy machine where the input and output alphabet are the same, and all transitions that read a letter 〈〉 also write 〈〉.

In our second Mealy machine problem, the question is whether, for a given input word, there is a computation of the Mealy machine which outputs a word that meets the census requirement.

figure g

By dynamic programming we show that two restrictions of this problem are in XP. In the first one, the census requirement is encoded in unary. This restriction of the problem seems lenient, especially when one is actually interested in finding the output word, as the census function acts then as a placeholder for the produced word.

Theorem 6

var-GWMM is in XP if c is encoded in unary.

Proof

Let |Σ∖{ϵ}|=σ and Σ∖{ϵ}={b 1,…,b σ }. Our dynamic programming algorithm computes the entries of a boolean table A. The table A has an entry A[s,c 1,…,c σ ,i,p] for each state sS, each c j ∈{0,…,c(b j )}, j∈[σ], each index i∈{0,…,|x|}, and each integer pP={0,…,|S|−1}. The entry A[s,c 1,…,c σ ,i,p] is set to true if there exists a computation of M reading the first i letters of x, outputting a word y in which the letter b j occurs c j times, for each j∈[σ], followed by p transitions that read ϵ and write ϵ, and ending up in state s, and to false otherwise.

Set A[s,c 1,…,c σ ,0,0] to true if s=s 0 and c 1=⋯=c σ =0, and to false otherwise. Compute the values of the table by increasing values of \(\sum _{i=1}^{\sigma}c_{i}\), index i, propagation integer p, and state number s:

Finally, there exists an x-computation of M generating a word y that meets the census requirement if and only if ⋁ sS,pP A[s,c(b 1),…,c(b σ ),|x|,p] is true. Denote by n is the length of the description of an input instance. The table has \(|S|\cdot|x|\cdot|P|\cdot \varPi _{j=1}^{\sigma} c(b_{j})\le|S|^{2} \cdot n^{\sigma+1}\) entries, and each entry can be computed in time O(|S|2σ). The running time of the algorithm is thus upper bounded by O(n σ+1k 5), where k is the parameter. □

For the version where c is encoded in binary, a restriction on the input alphabet gives an XP algorithm as well.

Corollary 2

var-GWMM is in XP if ϵΓ.

Proof

If ∑ bΣ∖{ϵ} c(b)>|x|, then return false, as M cannot output more than |x| letters. Otherwise, run the algorithm described in the proof of Theorem 6. Its running time is \(O(k^{5}\cdot|x| \cdot \varPi _{j=1}^{\sigma} c(b_{j}))= O(n^{\sigma+1} \cdot k^{5})\). □

Note that the XP-results also hold if the parameter is only |Σ|.

To show that var-GWMM is W[1]-hard, we reduce from the Multicolored Clique problem, which is W[1]-hard [8, 26].

figure h

Clearly, a solution to this problem has one vertex from each color.

Our parameterized reduction encodes G in the input word x of the Mealy machine M, and the description of M depends only on k. The Mealy machine is divided into k parts, one for each color class V(i), with 1≤ik. Its ith part is responsible for selecting a vertex v i from V(i) and edges v i v j for every v j V(j), with 1≤jik. All consistency issues and communication is done via the census requirement. Within part i, we need to make sure that the selected edges are all incident to the selected vertex v i . This is achieved by making M output p times each letter 〈l,i,j〉, with 1≤jik, if it selects the pth vertex in V(i). The census requirement for 〈l,i,j〉 is |V(i)|+1, meaning that 〈l,i,j〉 needs to be output |V(i)|+1−p times later. To select an edge v i v j , the machine M will be constrained to select this edge among the edges incident to v i . To achieve this, edges from V(i) to V(j) appear in x grouped by the vertex from V(i) on which they are incident. After each group of edges incident on one vertex from V(i), there is a special state where 〈l,i,j〉 is output if and only if the edge towards V(j) has already been selected. As 〈l,i,j〉 needs to be output exactly |V(i)|+1−p times, we force in this way that an edge is selected which is incident on v i . This enforces that all edges selected in the ith part are incident on the same vertex. It remains to make sure that distinct parts i and j select the same edge between V(i) and V(j). This is again achieved by a census requirement where a part of the census of letter \(\langle \mathbf{l},\bar{\mathbf{e}},i,j \rangle \) is output in the ith part and the remaining part in the jth part of M.

Theorem 7

var-GWMM is W[1]-hard.

Proof

Let (k,G=(V(1)∪V(2)∪⋯∪V(k),E)) be an instance of MCC. Suppose V(i)={v i,1,v i,2,…,v i,|V(i)|} is the vertex set of color i, for each color class i∈[k], E={e 1,e 2,…,e |E|}, and E(i,j)={e(i,j,1),e(i,j,2),…,e(i,j,|E(i,j)|)} is the subset of edges with one vertex in color class i and the other in color class j, for i,j∈[k]. Moreover, suppose E(i,j) follows the same order as E, that is if e p =e(i,j,p′), e q =e(i,j,q′), and pq, then p′≤q′. For a vertex v i,p and two integers j∈[k]∖{i} and q∈[d V(j)(v i,p )+1], we define gap(v i,p ,j,q)=ts, where e(i,j,t) is the qth edge in E(i,j) incident to v i,p (respectively, t=|E(i,j)| if q=d V(j)(v i,p )+1) and e(i,j,s) is the (q−1)th edge in E(i,j) incident to v i,p (respectively, s=0 if q=1).

We construct an instance (M=(S,s 0,Γ,Σ,T),x,c) for var-GWMM as follows. M’s input alphabet, Γ, is \(\{ \langle i \rangle , \langle i,j \rangle , \langle \bar{\mathbf{e}},i,j \rangle ,\langle \mathbf{e},i,j \rangle : i,j\in[k], i\not= j \}\). M’s output alphabet, Σ, is \(\{ \epsilon \} \cup \{ \langle \mathbf {l},i,j \rangle , \langle \mathbf{l},\bar{\mathbf{e}},i,j \rangle : i,j\in[k], i\not= j \}\). The word x is defined

The census requirement c is, for every \(i,j\in[k], i\not= j\),

On reading a subword x i , the Mealy machine will select a vertex v i,p in V(i) and one edge incident to v i,p for each color class j∈[k]∖{i}. The vertex v i,p is selected in the subword x i,0 of x i . Next, for each j∈[k]∖{i}, a vertex in V(i) and a vertex in V(j) are selected in the subword x i,j . The census requirement for 〈l,i,j〉 makes sure that the vertex from V(i) is v i,p . The subword x i,j,p ensures that v i,p and the vertex that is selected from V(j) are joined by an edge. Finally, the census requirement for \(\langle \mathbf{l},\bar{\mathbf{e}},i,j \rangle \) is responsible for the inter-partition communication and makes sure that the edge selected in x i,j is equal to the edge selected in x j,i .

The Mealy machine M consists of k parts. The ith part of M is depicted in Fig. 1. Its initial state is s v,1. There is a transition from the last state of each part, \(s_{e,i,k}^{(4)}\), to the first state of the following part, s v,i+1 (from the kth part, there is a transition to a final state): it reads the letter 〈i〉 and writes the letter ϵ. We set \(\langle \mathbf{l} ', \bar{\mathbf{e}},i,j \rangle =\langle \mathbf{l}, \bar{\mathbf{e}},j,i \rangle \) for all \(i \not= j \in[k]\). Note that, in the description of M, the letter 〈l,i,j〉 can only be output on reading 〈i,j〉, and \(\langle \mathbf {l}, \bar{\mathbf{e}},i,j \rangle \) can only be output on reading \(\langle \bar {\mathbf{e}},i,j \rangle \) or \(\langle \bar{\mathbf{e}},j,i \rangle \).

Fig. 1
figure 1

The ith part of the Mealy machine M. It does not have the states \(s_{e,i,i}^{(1)}, \protect s_{e,i,i}^{(2)}, \protect s_{e,i,i}^{(3)}\), and \(s_{e,i,i}^{(4)}\); there is instead a transition from \(s_{e,i,i-1}^{(4)}\) to \(s_{e,i,i+1}^{(1)}\) reading 〈i−1〉 and writing ϵ, and there is a transition from \(s_{e,k,k-1}^{(4)}\) to the last state reading 〈k〉 and writing ϵ. There are no transitions starting at the last state. (Drawing all this would have cluttered the figure too much)

Let us first verify that the parameter for var-GWMM is a function of k, and that there exists a function f such that the size of the instance for var-GWMM is f(k)⋅n O(1), where n is the number of vertices of G. We have |Γ|=k+3⋅k⋅(k−1), |Σ|=1+2⋅k⋅(k−1), and |S|=1+k⋅(2+4⋅(k−1)). The parameter of var-GWMM is thus bounded by a function of k. The length of x is O(k 2n 3). Now, we show that (M,x,c) is a Yes-instance for var-GWMM if and only if (G,k) is a Yes-instance for MCC.

First, suppose (M=(S,s 0,Γ,Σ,T),x,c) is a Yes-instance for var-GWMM.

We say that M selects a vertex v i,p if it makes a transition from state s v,i to state \(s'_{v,i}\) reading 〈i,k〉 (respectively 〈i,k−1〉 if i=k) for the pth time. In other words, in the ith part of M, it reads p⋅(k−1)−1 letters of x i,0, staying in state s v,i and outputs the letter 〈l,i,r〉 for each letter 〈i,r〉 it reads; then it transitions to state \(s'_{v,i}\) on reading 〈i,k〉 (respectively 〈k,k−1〉 if i=k) and outputs 〈l,i,k〉 (respectively 〈l,k,k−1〉); in the state \(s'_{v,i}\) it outputs the empty letter for each letter 〈i,r〉 it reads.

We say that M selects an edge e(i,j,q) if it makes a transition from state \(s_{e,i,j}^{(2)}\) to state \(s_{e,i,j}^{(3)}\) after having read the letter \(\langle \bar{\mathbf{e}},i,j \rangle \) of x i,j,p exactly q times, where v i,p is the vertex of color i that e(i,j,q) is incident on. In other words, in the ith part of M, it transitions from the state \(s_{e,i,j}^{(1)}\) to the state \(s_{e,i,j}^{(2)}\) on reading the first letter of x i,j,p (if it did this transition any later, the census requirement of \(\langle \mathbf{l},\bar{\mathbf{e}},i,j \rangle \) could not be met, as shown in the proof of Claim 2 below); then it stays in the state \(s_{e,i,j}^{(2)}\) until it has read q times the letter \(\langle \bar{\mathbf{e}},i,j \rangle \) of x i,j,p ; then it transitions to the state \(s_{e,i,j}^{(3)}\) on reading 〈e,i,j〉; it stays in this state and outputs \(\langle \mathbf{l} ',\bar{\mathbf {e}},i,j \rangle \) for each letter \(\langle \bar{\mathbf{e}},i,j \rangle \) it reads until transitioning to the state \(s_{e,i,j}^{(4)}\) on reading the letter following x i,j,p .

The following claims ensure that the edge-selection and the vertex-selection are compatible, i.e., that exactly one edge is selected from color i to color j, and that this edge is incident on the selected vertex of color i. □

Claim 1

Let i be a color and let v i,p be the vertex selected in the ith part of M. In its ith part, M selects one edge incident to v i,p and to a vertex of color j, for each j∈[k]∖{i}.

Proof

After M has selected v i,p , it has output p times each of the letters 〈l,i,1〉,〈l,i,2〉,…,〈l,i,i−1〉,〈l,i,i+1〉,〈l,i,i+2〉,…,〈l,i,k〉. For each j∈[k]∖{i}, the only other transitions that output 〈l,i,j〉 are the transition from \(s_{e,i,j}^{(3)}\) to \(s_{e,i,j}^{(4)}\) and a transition that loops on \(s_{e,i,j}^{(4)}\). To meet the census requirement of |V(i)|+1 for 〈l,i,j〉, M selects an edge while reading x i,j,p . This edge is incident on v i,p by construction. □

The following claim makes sure that the edge selected from color i to color j is the same as the edge selected from color j to color i.

Claim 2

Suppose M selects the edge e(i,j,q) in its ith part. Then, M selects the edge e(j,i,q) in its jth part.

Proof

Before M selects e(i,j,q), it has output q′≤q times the letter \(\langle \mathbf{l},\bar{\mathbf{e}},i,j \rangle \). On selecting e(i,j,q) it transitions to the state \(s_{e,i,j}^{(3)}\), and after the selection it outputs \(\langle \mathbf{l} ', \bar{e}, i, j \rangle \) for every letter \(\langle \bar{\mathbf{e}},i,j \rangle \) of x i,j,p it reads. As it reads

$$\Biggl(\sum_{r=1}^{d_{V(j)}(v_{i,p})+1} \mathsf {gap}(v_{i,p},j,r)\Biggr)-q = |E(i,j)|-q$$

times the letter \(\langle \bar{\mathbf{e}},i,j \rangle \) of x i,j,p after it has selected e(i,j,q), the Mealy machine outputs |E(i,j)|−q times the letter \(\langle \mathbf{l} ', \bar{e}, i, j \rangle \) in its ith part.

The only other transition where it outputs \(\langle \mathbf{l}, \bar {e}, i,j \rangle = \langle \mathbf{l} ', \bar{e} ,j,i \rangle \) is the transition in the jth part of M looping on \(s_{e,j,i}^{(3)}\) that reads \(\langle \bar{\mathbf{e}},j,i \rangle \) and outputs \(\langle \mathbf{l} ',\bar {\mathbf{e}},j,i \rangle \). To meet the census requirement for \(\langle \mathbf {l}, \bar{e},i,j \rangle \), this transition must be used exactly |E(i,j)|−q′ times.

The only other transitions where it outputs \(\langle \mathbf{l} ', \bar {e},i,j \rangle = \langle \mathbf{l}, \bar{e}, j, i \rangle \) are two transitions in the jth part of M: the transition from \(s_{e,j,i}^{(1)}\) to \(s_{e,j,i}^{(2)}\) and the transition looping on \(s_{e,j,i}^{(2)}\), both reading \(\langle \bar{\mathbf{e}},j,i \rangle \) and writing \(\langle \mathbf{l}, \bar{e},j,i \rangle \). These transitions can be used at most q′ times as the transition of the previous paragraph is used |E(i,j)|−q′ times. These transitions have to be used at least q times to meet the census requirement for \(\langle \mathbf{l} ',\bar{\mathbf{e}},i,j \rangle \). Thus, these transitions are used exactly q times and q=q′.

Finally, the transition from \(s_{e,j,i}^{(2)}\) to \(s_{e,j,i}^{(3)}\) happens after having read q times the letter \(\langle \bar{\mathbf {e}},j,i \rangle \) of some vertex x j,i,p,p′∈[|V(j)|], which means that M selects the edge e(j,i,q) in its jth part.

By Claims 1 and 2, the k vertices that are selected by M form a multicolored clique. Thus, (k,G=(V(1)∪V(2)∪⋯∪V(k),E)) is a Yes-instance for MCC.

Now, suppose that (k,G=(V(1)∪V(2)∪⋯∪V(k),E)) is a Yes-instance for MCC.

Let \(\{ v_{1,p_{1}},v_{2,p_{2}}, \ldots, v_{k,p_{k}} \}\) be a multicolored clique in G. We will construct a word y meeting c such that a computation of M on input x generates y. For two adjacent vertices \(v_{i,p_{i}}\) and \(v_{j,p_{j}}\), define \(\mathsf {edge}(v_{i,p_{i}},v_{j,p_{j}}) = t\) such that \(e(i,j,t) = v_{i,p_{i}} v_{j,p_{j}}\). The word y is y 1 y 2y k , where y i , for i∈[k], is

and y i,j , for \(i\not= j \in[k]\), is

We note that y meets the census requirement c. Moreover, the computation of M on input x, which selects (as defined in the first part of the proof) exactly the vertices and edges of the multicolored clique \(\{ v_{1,p_{1}},v_{2,p_{2}}, \ldots,v_{k,p_{k}} \}\), outputs y. Thus (M=(S,s 0,Γ,Σ,T),x,c) is a Yes-instance for var-GWMM. □

The theorem holds if we restrict ϵΓΣ. Indeed, ϵΓ in the target instance, and one can add a new letter e to Σ, which replaces ϵ and has census requirement \(c(e) = |x|-\sum_{i,j\in[k],i\ne j} (c(\langle \mathbf{l},i,j \rangle ) + c(\langle \mathbf{l},\bar{\mathbf{e}},i,j \rangle )\). This instance is equivalent since the modified M outputs one letter for each letter in x.

6 Applications

In this section we sketch two examples that illustrate how number-of-numbers parameterized problems may reduce to census problems about Mealy machines, parameterized by the size of the machine. For another application, see [10].

Example 1

(Heat-Sensitive Scheduling)

In a recent paper Chrobak et al. [5] introduced a model for the issue of temperature-aware task scheduling for microprocessor systems. The motivation is that different jobs with the same time requirements may generate different heat loads, and it may be important to schedule the jobs so that some temperature threshold is not breached.

In the model, the input consists of a set of jobs that are all assumed to be of unit length, with each job assigned a numerical heat level. If at time t the processor temperature is T t , and if the next job that is scheduled has heat level H, then the processor temperature at time t+1 is

$$T_{t+1} = (T_{t} + H)/2.$$

It is also allowed that perhaps no job is scheduled for time t+1 (that is, idle time is scheduled), in which case H=0 in the above calculation of the updated temperature.

The relevant decision problem is whether all of the jobs can be scheduled, meeting a specified deadline, in such a way that a given temperature threshold is never exceeded. This problem has been shown to be NP-hard [5] by a reduction from 3-Dimensional Matching. An image instance of the reduction, however, involves arbitrarily many distinct heat levels asymptotically close to H=2, for a temperature threshold of 1.

In the spirit of the “deconstruction of hardness proofs” advocated by Komusiewicz et al. [19] (see also [4, 24]), one might regard this problem as ripe for parameterization by the number of numbers, for example (scaling appropriately), a model based on 2k equally-spaced heat levels and a temperature threshold of k. Furthermore, if the heat levels of the jobs are only roughly classified in this way, it also makes sense to treat the temperature transition model similarly, as:

$$T_{t+1} = \lceil{ (T_{t} +H)/2} \rceil.$$

The input to the problem can now be viewed equivalently as a census of how many jobs there are for each of the 2k+1 heat levels, with the available potential units of idle time allowed to meet the deadline treated as “jobs” for which H=0. Because of the ceiling function modeling the temperature transition, the problem now immediately reduces to var-EWMM, for a machine on k+1 states (that represent the temperature of the processor) and an alphabet of size at most 2k+1. By Theorem 5, the problem is fixed-parameter tractable.

Example 2

(A Problem in Computational Chemistry)

The parameterized problem of Weighted Splits Reconstruction for Paths that arises in computational chemistry [15] reduces to a special case of var-GWMM. The input to the problem is obtained from time-series spectrographic data concerning molecular weights. The problem as defined in [15] is equivalent to the following two-processor scheduling problem. The input consists of

  • a sequence x of positive integer time gaps taken from a set of positive integers Γ, and

  • a census requirement c on a set of positive integers Σ of job lengths.

The question is whether there is a “winning play” for the following one-person two-processor scheduling game. At each step, first, Nature plays the next positive integer “gap” of the sequence of time gaps x—this establishes the next immediate deadline. Second, the Player responds by scheduling on one of the two processors, a job that begins at the last stop-time on that processor, and ends at the immediate deadline. The Player wins if there is a sequence of plays (against x) that meets the census requirement c on job lengths. Figure 2 illustrates such a game.

Fig. 2
figure 2

A winning game for the census: 1 (1), 3 (3), 4 (1), 5 (2)

This problem easily reduces to a special case of var-GWMM. Whether this special case is also W[1]-hard remains open.

7 Concluding Remarks

The practical world of computing is full of computational problems where inputs are “weighted” in a realistic model—weighted graphs provide a simple example relevant to many applications. Here we have begun to explore parameterizing on the numbers of numbers as a way of mitigating computational complexity for problems that are numerically structured. One might view some of the impulse here as moving approximation issues into the modeling, as illustrated by Example 1 in Sect. 6. We believe this line of attack may be widely applicable.

To date, there has been little attention to parameterized complexity issues in the context of cryptography, control theory, and other numerically structured areas of application. Number of numbers parameterization may provide some inroads into these underdeveloped areas.

Our main FPT result, Theorem 5, has a poor worst-case running-time guarantee. Can this be improved—at least in important special cases?