🤖 AI Summary
This paper addresses the automatic reverse synthesis of a finite-state machine (FSM) into an equivalent hierarchical FSM (HFSM). We propose a graph-theoretic, modular decomposition approach—introducing modular decomposition theory to automata theory for the first time—and define “thin modules” to recover algebraic structure, yielding a modular decomposition graph (MDG) that uniquely characterizes all equivalent thin HFSMs. We design an algorithm for module identification and HFSM synthesis with time complexity O(n²k), and address the bottleneck of minimizing the size of the largest component via a greedy optimization strategy. Empirical evaluation on the Harel watch benchmark demonstrates both effectiveness and scalability. Our core contribution is a formal theoretical framework for characterizing the hierarchical structure of FSMs, enabling the first reverse HFSM synthesis method that provides both rigorous formal guarantees and practical applicability.
📝 Abstract
Hierarchical Finite State Machines (HFSMs) are a standard software-modelling concept which extends the classical Finite State Machine (FSM) notion with the useful abstraction of hierarchical nesting. That is, an HFSM is an FSM whose states can be other FSMs. The hierarchy in HFSMs is provided at design time, and can be removed by expanding nested states, allowing HFSMs to inherit the semantics of FSMs. However, because hierarchy is a useful representation of the structure of an FSM, we would like to be able to invert this operation: given an FSM, can we compute equivalent HFSMs? This is the topic of this paper. By adapting the analogous theory of `modular decomposition' from graph theory into automata theory, we are able to compute an efficient representation of the space of equivalent HFSMs to a given one. Specifically, we first define a module of an FSM, which is a collection of nodes which can be treated as a nested FSM. Unlike modules in graphs, some modules in FSMs are lacking in algebraic structure. We identify a simple and natural restriction of the modules, called thin modules, which regain many of the critical properties from modules in graphs. We then construct a linear-space directed graph which uniquely represents every thin module, and hence every equivalent (thin) HFSM. We call this graph the modular decomposition. The modular decomposition makes clear the significant common structure underlying equivalent thin HFSMs. We provide an $O(n^2k)$ algorithm for constructing the modular decomposition of an $n$-state $k$-symbol FSM. We demonstrate the applicability of this theory on the following `bottleneck' problem: given an HFSM, find an equivalent one where the size of the largest component FSM is minimised. The modular decomposition gives a simple greedy algorithm for the bottleneck problem on thin HFSMs, which we demonstrate on a wristwatch HFSM example from Harel (1987).