Skip to main content

logaut

PyPI PyPI - Python Version PyPI - Status PyPI - Implementation PyPI - Wheel GitHub

test lint docs codecov

black

LOGics formalisms to AUTomata

What is logaut

Logaut is to the logics-to-DFA problem what Keras is for Deep Learning: a wrapper to performant back-ends, but with human-friendly APIs.

Install

To install the package from PyPI:

pip install logaut

Make sure to have Lydia installed on your machine. We suggest the following setup:

docker pull whitemech/lydia:latest
  • Make the Docker image executable under the name lydia. On Linux and MacOS machines, the following commands should work:
echo '#!/usr/bin/env sh' > lydia
echo 'docker run -v$(pwd):/home/default whitemech/lydia lydia "$@"' >> lydia
sudo chmod u+x lydia
sudo mv lydia /usr/local/bin/

This will install an alias to the inline Docker image execution in your system PATH. Instead of /usr/local/bin/ you may use another path which is still in the PATH variable.

On Windows, make a .bat file:

docker run --name lydia -v"%cd%":/home/default whitemech/lydia lydia %*

And add it to your PATH variable.

Quickstart

Now you are ready to go:

from logaut import ltl2dfa
from pylogics.parsers import parse_ltl
formula = parse_ltl("F(a)")
dfa = ltl2dfa(formula, backend="lydia")

The function ltl2dfa takes in input a pylogics formula and gives in output a pythomata DFA.

Then, you can manipulate the DFA as done with Pythomata, e.g. to print:

dfa.to_graphviz().render("eventually.dfa")

Currently, the lydia backend only supports the ltl and ldl logics.

The ltlf2dfa, based on LTLf2DFA, supports ltl and pltl. First, install it at version 1.0.1:

pip install git+https://github.com/whitemech/LTLf2DFA.git@develop#egg=ltlf2dfa

Then, you can use:

from logaut import pltl2dfa
from pylogics.parsers import parse_pltl
formula = parse_pltl("a S b")
dfa = pltl2dfa(formula, backend="ltlf2dfa")

Write your own backend

You can write your back-end by implementing the Backend interface:

from logaut.backends.base import Backend

class MyBackend(Backend):

    def ltl2dfa(self, formula: Formula) -> DFA:
        """From LTL to DFA."""

    def ldl2dfa(self, formula: Formula) -> DFA:
        """From LDL to DFA."""

    def pltl2dfa(self, formula: Formula) -> DFA:
        """From PLTL to DFA."""

    def pldl2dfa(self, formula: Formula) -> DFA:
        """From PLDL to DFA."""
        
    def fol2dfa(self, formula: Formula) -> DFA:
        """From FOL to DFA."""

    def mso2dfa(self, formula: Formula) -> DFA:
        """From MSO to DFA."""

Then, you can register the custom backend class in the library:

from logaut.backends import register
register(id_="my_backend", entry_point="dotted.path.to.MyBackend")

And then, use it through the main entry point:

dfa = ltl2dfa(formula, backend="my_backend")

Tests

To run tests: tox

To run only the code tests: tox -e py3.7

To run only the linters:

  • tox -e flake8
  • tox -e mypy
  • tox -e black-check
  • tox -e isort-check

Please look at the tox.ini file for the full list of supported commands.

Docs

To build the docs: mkdocs build

To view documentation in a browser: mkdocs serve and then go to http://localhost:8000

License

logaut is released under the GNU Lesser General Public License v3.0 or later (LGPLv3+).

Copyright 2021 WhiteMech

Authors

Metadata

Release files for logaut 0.2.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 logaut 0.2.0
File Size Uploaded
logaut-0.2.0.tar.gz 19.3 kB Details

Built distribution (wheel)

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

Total release size: 52.2 kB

Release files / logaut-0.2.0.tar.gz

Download URL logaut-0.2.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
35f82c7726dd53f6201fb6e440133e8d93b8a826810f7d3d8c46477afd6865bd
BLAKE2b-256 checksum
How to use checksums
75b903d0cf21bfcdec1d4981e6e89547410a6a115ec9d0d54e150ef158348d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / logaut-0.2.0-py3-none-any.whl

Download URL logaut-0.2.0-py3-none-any.whl
Size 32.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ebcda45a5a83ea4c60baed5ce8c90783c61763dfbab971b84d109939e9e6225
BLAKE2b-256 checksum
How to use checksums
604d73eb7d67d279cf858ec61a7c2d738eee4c01c1c331e6385ecf492331a3ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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