Skip to main content

Representation theory for automata, made practical.

Project description

morphata

morphata does representation theory for automata, and makes it practical.

An automaton -- its states, transitions, and acceptance condition -- is a structural object. Operators turn that structure into a quantitative interpretation: a matrix-valued morphism over a semiring, a multilinear polynomial over a bounded distributive lattice, or a BDD-canonicalised symbolic representation. morphata packages both halves -- the structures and the morphisms that interpret them -- in one library.

It builds on algebraic for backend-agnostic semiring algebra (NumPy, JAX, PyTorch).

Quick Start

Installation

pip install morphata

Basic Usage

import algebraic
import jax.numpy as jnp
from morphata.builder import AutomatonBuilder
from morphata.alphabet import weighted_alphabet
from morphata.operators.matrix import MatrixOperator
import logic_asts as logic

builder: AutomatonBuilder[int, str] = AutomatonBuilder()
builder.add_state(0, initial=True)
builder.add_state(1, accepting=True)
builder.add_transition(0, guard=logic.Variable("a"), succ=1)
aut = builder.build()

def xi(x, guard):
    return float(x[0])

alphabet = weighted_alphabet(xi=xi)
maxplus = algebraic.semirings.tropical_semiring(minplus=False)
op = MatrixOperator.from_nfa(aut, semiring=maxplus, alphabet=alphabet)

x = jnp.array([2.0])
transitions = op.cost_transitions(x)

For more, see the documentation.

Citation

If you use the matrix operator or this package, please cite one of:

  • For differentiable weighted automata in general:
@inproceedings{balakrishnan2024differentiable,
  title = {Differentiable {{Weighted Automata}}},
  booktitle = {{{ICML}} 2024 {{Workshop}} on {{Differentiable Almost Everything}}: {{Differentiable Relaxations}}, {{Algorithms}}, {{Operators}}, and {{Simulators}}},
  author = {Balakrishnan, Anand and Deshmukh, Jyotirmoy V.},
  year = 2024,
  month = jun,
  url = {https://openreview.net/forum?id=k2hIQYqHTh},
  copyright = {All rights reserved},
  langid = {english}
}
  • For weighted automata in motion planning:
@inproceedings{balakrishnan2024motion,
  title = {Motion {{Planning}} for {{Automata-based Objectives}} Using {{Efficient Gradient-based Methods}}},
  booktitle = {2024 {{IEEE}}/{{RSJ International Conference}} on {{Intelligent Robots}} and {{Systems}} ({{IROS}})},
  author = {Balakrishnan, Anand and Atasever, Merve and Deshmukh, Jyotirmoy V.},
  year = 2024,
  month = oct,
  pages = {13734--13740},
  issn = {2153-0866},
  doi = {10.1109/IROS58592.2024.10802177}
}
  • For alternating weighted automata in multi-agent systems:
@inproceedings{balakrishnan2025monitoring,
  title = {Monitoring {{Spatially Distributed Cyber-Physical Systems}} with {{Alternating Finite Automata}}},
  booktitle = {Proceedings of the 28th {{ACM International Conference}} on {{Hybrid Systems}}: {{Computation}} and {{Control}}},
  author = {Balakrishnan, Anand and Paul, Sheryl and Silvetti, Simone and Nenzi, Laura and Deshmukh, Jyotirmoy V.},
  year = 2025,
  month = may,
  pages = {1--11},
  publisher = {ACM},
  address = {Irvine CA USA},
  doi = {10.1145/3716863.3718033},
  isbn = {979-8-4007-1504-4},
  langid = {english}
}

License

See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

morphata-2.0.5.tar.gz (342.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

morphata-2.0.5-py3-none-any.whl (87.9 kB view details)

Uploaded Python 3

File details

Details for the file morphata-2.0.5.tar.gz.

File metadata

  • Download URL: morphata-2.0.5.tar.gz
  • Upload date:
  • Size: 342.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for morphata-2.0.5.tar.gz
Algorithm Hash digest
SHA256 bb2d38d73054c0baa8d08768b805f549dec4508d92d07ca958f693bb3de1b255
MD5 7df92c14b90f7d65f08008b5f0f0180f
BLAKE2b-256 c8d930ce0f636b8d144b078a77ee742d8da34ae68ca27fe5937b8f3d1de49f7d

See more details on using hashes here.

File details

Details for the file morphata-2.0.5-py3-none-any.whl.

File metadata

  • Download URL: morphata-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for morphata-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b5e21ab3d854f7290093b08dfead548450d59c481601b73e3776c1d11c660f81
MD5 e6a493db8fcddbca4972cd374b9a5055
BLAKE2b-256 5e9ed89e7e6f378f6eb2b9a2de65c301fe7d350b69791d2c7462b0cfaccc48cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page