Package: libmata
Mata: The Automata LibraryMata is an open source automata library that offers interface for different kinds of automata (NFA, etc.). Currently, Mata offers two interfaces:An efficient library implemented in C/C++A flexible wrapper implemented in Python that uses the efficient libraryRequirements and dependenciesFor a successful installation of Mata,cmakeof version3.15.0(or higher) and a C++ compiler with a support of C++-20 standard is required.
From optional requirements,doxygenis required for a generation of the documentation andcatch2is required for the unit testing (Mata can still be compiled without these optional dependencies).The Mata library further depends on the following libraries, included in the3rdpartydirectory:cuddfor BDD manipulation,re2for regular expression parsing and the corresponding automata construction, andsimlibfor a simulation computation.Building and installing from sourcesTo build the library, run the following:git clone https://github.com/VeriFIT/mata
cd mata
make releaseIn order to install the library, you can runsudo make installIn order to verify the functionality of the library, you can run the test suite:make testYou might, need to install the dependencies to measure the coverage of the tests.
Run the following to install the dependencies for MacOS:brew install lcov gcovrRun the following to install the dependencies for Ubuntu:sudo apt-get install -y build-essential lcov gcovr xdg-utilsPython bindingMata offers binding of its efficient library to Python. You can install the binding as an Python
package on your system as follows.Install from PyPITo install a latest version from the PyPI repository, runpip3 install libmataBuilding from sourcesTo build from sources first, install the necessary requirements for Python and your
system. We recommend using the virtual environemnt (venv) to install and use the library.python -m pip install --upgrade pip
make -C bindings/python init

sudo apt-get -qq update 
sudo apt-get -qq install -y graphviz graphviz-devNow, you can install the library.make -C bindings/python installFinally, you can verify the binding woks as expected by running the test suite:make -C bindings/python testGetting startedTo get started, we refer to theexamplesin our repository.
This directory contains examples of various usage in form of:C/C++ example programs. By default, they are built with the library. To run for example the first example:./build/examples/example01-simplePython example scripts. To run the scripts run the following.python examples/example01-python-binding.pyPython jupyter notebooks. To run the jupyter notebook, one needs to have jupyter installed as
a prerequisite. The run the jupyter notebook, that creates an instance on your local server.
Navigate to generated link to see the available jupyter notebooks:pip3 install jupyter
jupyter notebookUsing the libraryThe library can be used directly in the C/C++ code. The result of compilation is a static
or dynamic library, that can be linked to ones project. Note, that the library is dependent
on several other 3rd party libraries (e.g.,libre2orlibsimlib), which are included in
the repository.First import the library in your code. If the library is properly installed, you can use
the standard include.#include<mata/nfa/nfa.hh>We recommend to use themata::nfanamespace for easier usage:usingnamespacemata::nfa;Start by creating an automaton with fixed number of states.intmain(){Nfaaut(4);You can set the initial and final states directly using the initializers.aut.initial={0,1};aut.final={2,3};Further, you can add transitions in form of tripple(state_from, symbol, targets):aut.delta.add(0,0,2);aut.delta.add(1,1,3);You can verify the state of your automaton by generating the automaton in.dotformat.aut.print_to_DOT(std::cout);return0;}We recommendcmakefor building projects using Mata. Provided the Mata is installed in the system directories,
theCMakeLists.txtfile for the example may look like:cmake_minimum_required(VERSION3.15.0)project(mata-example)set(CMAKE_CXX_STANDARD20)find_library(LIBMATAmataREQUIRED)add_executable(mata-examplemata-example.cc)target_link_libraries(mata-examplePUBLIC${LIBMATA})Using the Python bindingThe python binding is installed (by default) to your local python package repository. You can
either use the binding in your own scripts or in the python interpreter.You can start using the binding by importing thelibmatapackage.importlibmata.nfa.nfaasmata_nfaIn your own scripts, we recommend to use the standard guard for running the scripts, as follows.if__name__=="__main__":The usage of the binding copies (to certain levels) the usage of the C++ library.aut=mata_nfa.Nfa(4)aut.initial_states={0,1}aut.final_states={2,3}aut.add_transition(0,0,2)aut.add_transition(1,1,3)print(aut.to_dot_str())You can either run your scripts directly usingpythonor compile it using thecythonproject.ContributingIf you'd like to contribute to the libmata,
pleasefork the repository, create a new
feature branch, and finallycreate a new pull request.In case you run into some unexpected behaviour, error or anything suspicious
either contact us directly through mail orcreate a new issue.
When creating a new issue, please, try to include everything necessary for us to know
(such as the version, operation system, etc.) so we can sucessfully replicate the issue.Note to main contributorsBy default, each merge automatically increases theminorversion of the library
(i.e.,0.0.0 -> 0.1.0). This can be overruled using either tag#patch(increasing
patch version, i.e.,0.0.0 -> 0.0.1) or#major(increasing major version, i.e.,0.0.0 -> 1.0.0). This tag is specified in the merge message.Generally, it is recommended to use#majorfor changes that introduces backward-incompatible
changes for people that used previous versions, and#patchfor minor changes, such as bug-fixes,
performance fixes or refactoring.LinksProject (origin) repository:https://github.com/verifit/mataIssue tracker:https://github.com/verifit/mata/issuesIn case of some sensitive bugs (like security vulnerabilities),
please contact us directly, instead of using issue tracker.
We value your effort to improve the security and privacy of this project!Project documentation:https://verifit.github.io/mataJupyter notebooks demonstratingmatausage:https://github.com/VeriFIT/mata/tree/devel/examples/notebooksExample 01: WS1S LogicExample 02: ReDoS AttacksExample 03: Exploring MazeAlso, check out our research group focusing on program analysis, static and dynamic analysis,
formal methods, verification and many more:http://www.fit.vutbr.cz/research/groups/verifit/index.php.en.LicensingThe code of Mata is licensed under MIT licence. SeeLICENSE.The folder3rdparty/contains 3rd party applications licensed under their own licences, included with the code.ContactsSeeAUTHORS.mdAcknowledgementsWe thank for the support received from the Brno University of Technology
(BUT FIT).Development of this tool has been supported by the following projects: ???.This tool as well as the information provided on this web page reflects
only the author's view and no organization is responsible for any use
that may be made of the information it contains.