Skip to main content

Answer Set Programming with a friendly interface.

Project description

ASPish - Answer Set Programming for Python

ASPish is a library that aims to provide some parts of ASP (Anser Set Programming) in a Python-friendly way. All the heavy lifting is done by clingo, a mature implementation of ASP. This library merely provides an interface that allows for a more streamlined usage from Python than the official Python bindings.

ASP can be approximately viewed as the combination of query language that extends datalog, and a satisfiability solver. Both are integrated into a single coherent language which makes ASP particularly convenient when dealing with relational data.

Currently, this project is in early stages and focuses primarily on the query language part.

Basic Usage

from aspish import Solver, predicate, var

# declarations
edge = predicate('edge', ('x', 'y'))
path = predicate('path', ('x', 'y'))

solver = Solver()
X, Y, Z = map(var, 'XYZ')

# add facts
solver.add(
    edge(1, 2),
    edge(2, 3)
)

# add rules
solver.add(
    path(X, Y) <= edge(X, Y),
    path(X, Y) <= (
        edge(X, Z),
        path(Z, Y)
    )
)

# run
solver.solve()
solver.get(path)

# returns
[path(x=1, y=2), path(x=2, y=3), path(x=1, y=3)]

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

aspish-0.6.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

aspish-0.6.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file aspish-0.6.0.tar.gz.

File metadata

  • Download URL: aspish-0.6.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/24.6.0

File hashes

Hashes for aspish-0.6.0.tar.gz
Algorithm Hash digest
SHA256 5592e30fbaff2ea0f2a88f28784d5c1c1791e55bfdbc1f6a3ddf1c40c8fef5ac
MD5 33cb23bbe17181e6ad7f643028bc7c43
BLAKE2b-256 deecc632e78401b5476ec91a8ef04145f36faaeb2c5739b489a13fec75aed316

See more details on using hashes here.

File details

Details for the file aspish-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: aspish-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/24.6.0

File hashes

Hashes for aspish-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 995288b53079ed632f5097d7be08cbe5ed4c0dfd55088c4ff2df0f661033b98e
MD5 0706383c58ab00f7e74134b077e1f248
BLAKE2b-256 34b956527b6d19262cd28e9e4154ad400d3f418ccb685092123a7b91b05cacea

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