Learning Deterministic Finite-State Machines from the Prefixes of a Single String is NP-Complete
Radu Cosmin Dumitru, Ryo Yoshinaka, Ayumi Shinohara
TL;DR
This work investigates learning a smallest DFA from prefix-closed samples, which corresponds to recovering a minimum Moore machine along a single run. Through a sequence of polynomial-time reductions from Graph Coloring, it establishes NP-completeness for ConDFA/ConADFA with binary alphabets and prefix-complete samples, and extends the hardness to Moore/Mealy variants. It further proves inapproximability results: no polynomial-time polynomial-ratio approximation is possible for these prefix-complete instances unless P=NP, and hardness persists when samples are prefixes of a single string. These results reveal that even highly structured, trace-like data remain intractable for automata learning, informing the limits of tractable learning and guiding future research on restricted approximation or heuristic approaches in trace-based settings.
Abstract
It is well known that computing a minimum DFA consistent with a given set of positive and negative examples is NP-hard. Previous work has identified conditions on the input sample under which the problem becomes tractable or remains hard. In this paper, we study the computational complexity of the case where the input sample is prefix-closed. This formulation is equivalent to computing a minimum Moore machine consistent with observations along its runs. We show that the problem is NP-hard to approximate when the sample set consists of all prefixes of binary strings. Furthermore, we show that the problem remains NP-hard as a decision problem even when the sample set consists of the prefixes of a single binary string. Our argument also extends to the corresponding problem for Mealy machines.
