Skip to main content
AALpy Logo

Python application CodeQL PyPI - Downloads

GitHub issues GitHub pull requests Python 3.10 PyPI - Wheel Maintenance License: MIT


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.

Automata Type Supported Formalisms Active Algorithms Passive Algorithms
Deterministic DFAs
Mealy Machines
Moore Machines
L*
KV
L#
hW
RPNI
EDSM
Non-Deterministic ONFSM
Non-deterministic Moore Machines
Abstracted ONFSM
L*ONFSM k-tails
Stochastic Markov Decision Processes
Stochastic Mealy Machines
Markov Chains
L*MDP
L*SMM
Alergia
IoAlergia
AlergiaEDSM
Pushdown VPA/SEVPA KVVPA PAPNI

Extension of AALpy that are early-research prototypes, support non-conventional formalisms and algorithms, or carry heavy dependencies can be found in AALpy-extra.

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.10. If you want to use older Python version (>= 3.6), you can use AALpy versions up to 1.6.2.

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

High level introduction to automata learning can be found at the following Medium post. 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:

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:

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. We are happy to help you and consult you in developing automata learning algorithms and in applying automata learning in various domains.

Testing

Install the test dependencies once (pytest and pytest-timeout aren't needed to use AALpy itself, only to run its test suite):

pip install -e .[test]

Then, from the repository root, run AALpy's test suite:

pytest

For a more comprehensive test suite, which covers more seeds per learning experiment, run:

pytest --exhaustive

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.

Metadata

Release files for aalpy 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aalpy 2.0.0
File Size Uploaded Provenance Actions
aalpy-2.0.0.tar.gz 204.2 kB Without provenance Details for aalpy-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aalpy 2.0.0
File Interpreter ABI Platform Actions
aalpy-2.0.0-py3-none-any.whl Python 3 none any Details for aalpy-2.0.0-py3-none-any.whl

Total release size: 460.8 kB

Release files / aalpy-2.0.0.tar.gz

Download URL aalpy-2.0.0.tar.gz
Size 204.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a00708fb86ce2d490d298ad514c3722b0435b3249a9d0f3b556211180937b8d5
BLAKE2b-256 checksum
How to use checksums
d29121694c92ab6b8085242ccc4d099e2ecd3dee26c38269f3bacacea0e6f662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / aalpy-2.0.0-py3-none-any.whl

Download URL aalpy-2.0.0-py3-none-any.whl
Size 256.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1300a55c430948ab0f2f1a31945cdc50d5bbbc1cef6dbd44b981ebe0f6416557
BLAKE2b-256 checksum
How to use checksums
2c3a2dfa24db513638add8519554b3722e5acec904060ad22f71aa694c096085
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Security for aalpy 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page