An active automata learning library
Project description
AALpy is a light-weight automata learning library written in Python. You can start learning models of black-box systems with a few lines of code.
AALpy supports both active and passive automata learning algorithms that can be used to learn a variety of modeling formalisms, including deterministic, non-deterministic, and stochastic automata, as well as deterministic context-free grammars/pushdown automata.
Automata Type | Supported Formalisms | Algorithms | Features |
---|---|---|---|
Deterministic | DFAs Mealy Machines Moore Machines |
L* KV RPNI |
Seamless Caching Counterexample Processing 13 Equivalence Oracles |
Non-Deterministic | ONFSM Abstracted ONFSM |
L*ONFSM | Size Reduction Trough Abstraction |
Stochastic | Markov Decision Processes Stochastic Mealy Machines Markov Chains |
L*MDP L*SMM ALERGIA |
Counterexample Processing Exportable to PRISM format Bindings to jALERGIA |
Pushdown | VPA/SEVPA | KVVPA PAPNI |
Passive learning of VPAs Exclusive call-return pairs |
Installation
Use the package manager pip to install the latest release of AALpy:
pip install aalpy
To install current version of the master branch (it might contain bugfixes and added functionalities between releases):
pip install https://github.com/DES-Lab/AALpy/archive/master.zip
The minimum required version of Python is 3.6.
Ensure that you have Graphviz installed and added to your path if you want to visualize models.
For manual installation, clone the repo and install pydot
(the only dependency).
Documentation and Wiki
If you are interested in automata learning or would like to understand the automata learning process in more detail, please check out our Wiki. On Wiki, you will find more detailed examples on how to use AALpy.
Examples.py contains examples covering almost the whole of AALpy's functionality and its a great starting point.
Usage
All active automata learning procedures follow this high-level approach:
- Define the input alphabet and system under learning (SUL)
- Choose the equivalence oracle
- Run the learning algorithm
Passive learning algorithm simply require you to provide data in the appropriate format (check Wiki and Examples) and run the learning function.
Code snipped demonstrating some of AALpy's functionalities
The following snippet demonstrates a short example in which an automaton is either loaded or randomly generated and then learned.
from aalpy.utils import load_automaton_from_file, generate_random_deterministic_automata
from aalpy.SULs import AutomatonSUL
from aalpy.oracles import RandomWalkEqOracle
from aalpy.learning_algs import run_Lstar, run_KV
# load an automaton
# automaton = load_automaton_from_file('path_to_the_file.dot', automaton_type='dfa')
# or randomly generate one
random_dfa = generate_random_deterministic_automata(automaton_type='dfa', num_states=8,
input_alphabet_size=5, output_alphabet_size=2)
# get input alphabet of the automaton
alphabet = random_dfa.get_input_alphabet()
# loaded or randomly generated automata are considered as BLACK-BOX that is queried
# learning algorithm has no knowledge about its structure
# create a SUL instance for the automaton/system under learning
sul = AutomatonSUL(random_dfa)
# define the equivalence oracle
eq_oracle = RandomWalkEqOracle(alphabet, sul, num_steps=5000, reset_prob=0.09)
# start learning
# run_KV is for the most part reacquires much fewer interactions with the system under learning
learned_dfa = run_KV(alphabet, sul, eq_oracle, automaton_type='dfa')
# or run L*
# learned_dfa_lstar = run_Lstar(alphabet, sul, eq_oracle, automaton_type='dfa')
# save automaton to file and visualize it
# save_automaton_to_file(learned_dfa, path='Learned_Automaton', file_type='dot')
# or
learned_dfa.save()
# visualize automaton
# visualize_automaton(learned_dfa)
learned_dfa.visualize()
# or just print its DOT representation
print(learned_dfa)
To make experiments reproducible, define a random seed at the beginning of your program.
from random import seed
seed(2) # all experiments will be reproducible
Selected Applications
AALpy has been used to:
- Learn Models of Bluetooth Low-Energy
- Find bugs in VIM text editor
- Learn Input-Output Behavior of RNNs
- Learn Models of GIT
- Solve RL Problems
Cite AALpy and Research Contact
If you use AALpy in your research, please cite us with of the following:
If you have research suggestions or you need specific help concerning your research, feel free to start a discussion or contact edi.muskardin@silicon-austria.com. We are happy to help you and consult you in applying automata learning in various domains.
Contributing
Pull requests are welcome. For significant changes, please open an issue first to discuss what you would like to change. In case of any questions or possible bugs, please open issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file aalpy-1.4.2-py3-none-any.whl
.
File metadata
- Download URL: aalpy-1.4.2-py3-none-any.whl
- Upload date:
- Size: 131.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.13.0 pkginfo/1.7.0 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13f533ba70807b729841cd79267233a329472dda0f510c83fc8e53f767384abe |
|
MD5 | b23e5938f087f092e77925ed0c59dfeb |
|
BLAKE2b-256 | 05cc957218fc03c407bad3796a4aea48162d5a9c167f895af36e7750fee9062f |