Package: aalpy
AALpyAn Active Automata Learning LibraryAALpy is a light-weight automata learning library written in Python.
You can start learning automata in just a few lines of code.Whether you work with regular languages or you would like to learn models of
(black-box) reactive systems, AALpy supports a wide range of modeling formalisms, includingdeterministic,non-deterministic, andstochastic automata,
as well asdeterministic context-free grammars/pushdown automata.Automata TypeSupported FormalismsAlgorithmsFeaturesDeterministicDFAsMealy MachinesMoore MachinesL*KVRPNISeamless CachingCounterexample Processing13 Equivalence OraclesNon-DeterministicONFSMAbstracted ONFSML*ONFSMSize Reduction  Trough AbstractionStochasticMarkov Decision ProcessesStochastic Mealy MachinesMarkov ChainsL*MDPL*SMMALERGIACounterexample ProcessingExportable to PRISM formatBindings to jALERGIAPushdownVPDA/SEVPAKVVPASpecification of exclusivecall-return pairsAALpy enables efficient learning by providing a large set of equivalence oracles, implementing various conformance testing strategies. Active learning
is mostly based on Angluin'sL* algorithm, for which AALpy supports a
selection of optimizations, including efficient counterexample processing caching. However, the recent addition of efficiently implementedKValgorithm
requires (on average) much less interaction with the system under learning than L*. In addition, KV can be used to learn Visibly Deterministic Pushdown Automata (VPDA).AALpy also includespassive automata learning algorithms, namely RPNI for deterministic and ALERGIA for stochastic models. Unlike active algorithms which learn by interaction with the system, passive learning algorithms construct a model based on provided data.InstallationUse the package managerpipto install the latest release of AALpy:pipinstallaalpyTo install current version of the master branch (it might contain bugfixes and added functionalities between releases):pipinstallhttps://github.com/DES-Lab/AALpy/archive/master.zipThe minimum required version of Python is 3.6.Ensure that you haveGraphvizinstalled and added to your path if you want to visualize models.For manual installation, clone the repo and installpydot(the only dependency).Documentation and WikiIf you are interested in automata learning or would like to understand the automata learning process in more detail,
please check out ourWiki. On Wiki, you will find more detailed examples on how to use AALpy.https://github.com/DES-Lab/AALpy/wikiExamples.pycontains many examples and it is a great starting point.UsageAll automata learning procedures follow this high-level approach:Define the input alphabet and system under learning (SUL)Choose the equivalence oracleRun the learning algorithmFor more detailed examples, check out:How to learn Regex with AALpyHow to learn MQTT with AALpyFew Simple ExamplesInteractive ExamplesExamples.pyExamples.pycontains examples covering almost the whole of AALpy's functionality, and it is a great starting point/reference.Wikihas a step-by-step guide to using AALpy and can help you understand AALpy and automata learning in general.Code snipped demonstrating some of AALpy's functionalitiesThe following snippet demonstrates a short example in which an automaton is eitherloadedorrandomly generatedand thenlearned.fromaalpy.utilsimportload_automaton_from_file,save_automaton_to_file,visualize_automaton,generate_random_dfafromaalpy.automataimportDfafromaalpy.SULsimportAutomatonSULfromaalpy.oraclesimportRandomWalkEqOraclefromaalpy.learning_algsimportrun_Lstar,run_KV# load an automaton# automaton = load_automaton_from_file('path_to_the_file.dot', automaton_type='dfa')# or construct it from state setupdfa_state_setup={'q0':(True,{'a':'q1','b':'q2'}),'q1':(False,{'a':'q0','b':'q3'}),'q2':(False,{'a':'q3','b':'q0'}),'q3':(False,{'a':'q2','b':'q1'})}small_dfa=Dfa.from_state_setup(dfa_state_setup)# or randomly generate onerandom_dfa=generate_random_dfa(alphabet=[1,2,3,4,5],num_states=20,num_accepting_states=8)big_random_dfa=generate_random_dfa(alphabet=[1,2,3,4,5],num_states=2000,num_accepting_states=500)# get input alphabet of the automatonalphabet=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 learningsul=AutomatonSUL(random_dfa)# define the equivalence oracleeq_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 learninglearned_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')# orlearned_dfa.save()# visualize automaton# visualize_automaton(learned_dfa)learned_dfa.visualize()# or just print its DOT representationprint(learned_dfa)To make experiments reproducible, define a random seed at the beginning of your program.fromrandomimportseedseed(2)# all experiments will be reproducibleSelected ApplicationsAALpy has been used to:Learn Bluetooth Low-EnergyLearn Input-Output Behavior of RNNsFind bugs in VIM text editorCite AALpy and Research ContactIf you use AALpy in your research, please cite us with of the following:Extended version (preferred)Tool paperIf you have research suggestions or you need specific help concerning your research, feel free to start adiscussionor contactedi.muskardin@silicon-austria.com.
We are happy to help you and consult you in applying automata learning in various domains.ContributingPull 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.