Skip to main content

ML2: Machine Learning for Mathematics and Logics

https://img.shields.io/pypi/pyversions/ml2 https://img.shields.io/pypi/v/ml2 https://img.shields.io/github/license/reactive-systems/ml2

ML2 is an open source Python library for machine learning research on mathematical and logical reasoning problems. The library includes the (re-)implementation of the research papers Teaching Temporal Logics to Neural Networks and Neural Circuit Synthesis from Specification Patterns. So far, the focus of ML2 is on propositional and linear-time temporal logic (LTL) and transformer architectures. ML2 is actively developed at CISPA Helmholtz Center for Information Security.

Requirements

Note on Docker: For data generation, evaluation, and benchmarking ML2 uses a variety of research tools (e.g. SAT solvers, model checkers, and synthesis tools). For ease of use, each tool is encapsulated in a Docker container that is automatically pulled and started when the tool is needed. Thus, ML2 requires Docker to be installed and running.

Installation

Before installing ML2, please note the Docker requirement.

From PyPI

Install ML2 from PyPI with pip install ml2.

From Source

To install ML2 from source, clone the git repo and install with pip as follows:

git clone https://github.com/reactive-systems/ml2.git && \
cd ml2 && \
pip install .

For development pip install in editable mode and include the development dependencies as follows:

pip install -e .[dev]

Neural Circuit Synthesis (presented at NeurIPS 21)

In this project, hierarchical Transformers were trained to synthesize hardware circuits directly out of high-level specifications in a temporal logic. The lack of sufficient amounts of training data was tackled with a method to generate large amounts of additional training data, i.e., pairs of specifications and circuits implementing them by mining common specification patterns from the annual synthesis competition SYNTCOMP.

Training

To train a hierarchical Transformer with default parameters:

python -m ml2.experiment.run configs/ltl-syn/neurips21/ht.json

Evaluation

To evaluate a hierarchical Transformer trained on the circuit synthesis task:

python -m ml2.experiment.run configs/ltl-syn/neurips21/ht-sem-eval.json`

Datasets and Data Generation

To generate a dataset of specifications and AIGER circuits:

python -m ml2.ltl.ltl_syn.ltl_syn_data_gen_patterns --name dataset`

How to Cite

@inproceedings{neural_circuit_synthesis,
    author    = {Frederik Schmitt and Christopher Hahn and Markus N. Rabe and Bernd Finkbeiner},
    title     = {Neural Circuit Synthesis from Specification Patterns},
    booktitle = {Advances in Neural Information Processing Systems 34 Pre-proceedings},
    year      = {2021}
    url       = {https://proceedings.neurips.cc/paper/2021/hash/8230bea7d54bcdf99cdfe85cb07313d5-Abstract.html}
}

Teaching Temporal Logics to Neural Networks (presented at ICLR 21)

In this project, Transformers were trained on the problem of finding a satisfying trace to a linear-time temporal logic (LTL) formula. While the training data was generated with classical solvers, providing only one of a possibly infinite number of solutions, the Transformers successfully generalized: while often deviating from the solutions found by the classical solver, they still predicted a correct solution to most formulas. Generalization was also demonstrated on larger formulas and formulas on which the classical solver timed out.

Training

To train a Transformer with default parameters on the trace generation problem:

python -m ml2.experiment.run configs/ltl-strace/iclr21/t.json

For the propositional satisfiability experiment:

python -m ml2.experiment.run configs/prop-sat/iclr21/t.json

Evaluation

To evaluate a Transformer trained on the trace generation problem:

python -m ml2.experiment.run configs/ltl-strace/iclr21/t-sem-eval.json`

How to Cite

@inproceedings{teaching_temporal_logics,
    title     = {Teaching Temporal Logics to Neural Networks},
    author    = {Christopher Hahn and Frederik Schmitt and Jens U. Kreber and Markus N. Rabe and Bernd Finkbeiner},
    booktitle = {International Conference on Learning Representations},
    year      = {2021},
    url       = {https://openreview.net/forum?id=dOcQK-f4byz}
}

Metadata

Release files for ml2 0.2.1

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

Source distribution (sdist)

Source distribution for ml2 0.2.1
File Size Uploaded Provenance
ml2-0.2.1.tar.gz 235.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 638.8 kB

Release files / ml2-0.2.1.tar.gz

Download URL ml2-0.2.1.tar.gz
Size 235.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8fbb1b2b84a25dda56183193e3379d6f27454eb622ece1c82218b8ec9e98a5df
BLAKE2b-256 checksum
How to use checksums
2fae78551c3110ab4ade6d9a2ff1732f8ccabe0df8709b6bd55553433dbbd1df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / ml2-0.2.1-py3-none-any.whl

Download URL ml2-0.2.1-py3-none-any.whl
Size 403.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2df0c38b25faec64da47ddea899246f86a0d7ae2c3aee78d2dc6ff765e93cea0
BLAKE2b-256 checksum
How to use checksums
9e4cf2b9af70f7d5a7412f544f7f263b832d769a61d61ff2e02ebe2fd73db184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for ml2 0.2.1

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.

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