TL;DR
AALpy is the first comprehensive, open-source Python library for active automata learning, allowing researchers to automatically "mine" formal models from black-box systems. It supports a wide range of models—from deterministic finite-state machines to stochastic systems—and bridges the gap between formal verification tools and the modern Python-centric AI/ML ecosystem.
What Problem Does This Paper Address?
In software engineering and security, we often encounter "black-box" systems where the internal source code or logic is unknown. To perform rigorous testing, model checking, or formal verification, we need a mathematical model (an automaton) of how that system behaves.
Active automata learning solves this by interacting with the system—sending inputs and observing outputs—to incrementally build a model. While Java-based tools like LearnLib have been the industry standard, the lack of a robust Python equivalent has been a barrier. Python is the primary language for many modern interfaces (like Scapy for networking or PyTorch for AI), making it the ideal "glue" for learning the behavior of real-world reactive systems.
Methods
AALpy implements the Minimally Adequate Teacher (MAT) framework. The process involves two alternating phases:
- Exploitation (Membership Queries): The learner asks the system what happens given a specific sequence of inputs to build a hypothesis model.
- Exploration (Equivalence Queries): The learner asks an "Oracle" if the hypothesis is correct. If not, the Oracle provides a counterexample to refine the model.
Key Technical Features: * Broad Model Support: Unlike many tools, AALpy handles Deterministic (DFA, Mealy, Moore), Non-deterministic (ONFSM), and Stochastic models (SMMs, MDPs). * Advanced $L^*$ Extensions: It includes optimized versions of the $L^*$ algorithm with various counterexample processing techniques (e.g., Rivest-Schapire) to improve efficiency. * Extensive Oracle Library: It provides 11 different equivalence oracles, ranging from formal methods like the W-method to randomized heuristics like Random Walk and PAC (Probably Approximately Correct) oracles.
Datasets
As a tool-focused paper, the authors evaluated AALpy using several benchmarks:
- Synthetic Benchmarks: Randomly generated DFAs and Mealy machines with varying state sizes (up to 5,000) and alphabet sizes (up to 100).
- Stochastic Benchmarks: Models including a 35-state grid, a 72-state grid, a "Shared Coin" protocol, and a Slot Machine model.
- Real-World Case Studies: The library was applied to learn the behavior of Bluetooth Low Energy (BLE) devices, the VIM text editor, and to extract models from Recurrent Neural Networks (RNNs).
Key Insights and Ideas
- The "Interaction Bottleneck": The authors found that in real-world scenarios (like testing a network protocol), the time spent waiting for the system to respond (SUL interaction time) far outweighs the internal computation time of the learning library. This justifies using Python over a faster language like Java or C++.
- Python as a Testing "Glue": Because AALpy is in Python, it can natively use libraries like
Scapyto talk to hardware orKerasto probe neural networks, which is significantly more difficult in Java-based frameworks. - Stochastic Robustness: The implementation of the $L^*_{SMM}$ algorithm is noted for being more robust to sparse observations than previous implementations, making it more practical for real-world stochastic systems.
Key Results
- Performance Parity: In head-to-head tests with LearnLib, AALpy showed comparable performance. While LearnLib is slightly faster for small alphabets due to Java's static typing, AALpy actually performed better on DFAs with very large alphabets.
- Scalability: Learning time and the number of steps required scale linearly with the number of states and alphabet size for deterministic models.
- Real-World Impact:
- VIM Bug Hunting: AALpy was used to find non-deterministic behavior in the VIM text editor, leading to a bug report that was subsequently fixed by the community.
- BLE Fingerprinting: The tool successfully learned models for five different BLE devices, creating "fingerprints" that could uniquely identify the hardware based on its protocol implementation.
Limitations and Future Work
- Reset Requirement: Most algorithms in AALpy currently require the ability to "reset" the system to an initial state, which isn't always possible in the real world.
- Future Directions: The authors plan to integrate SAT-based learning (which can be more efficient for certain model types) and explore learning without resets. They also aim to add support for probabilistic black-box reachability checking.
Summary updated