Tools to aid the development of explanation systems using clingo
Project description
clingexplaid
API to aid the development of explanation systems using clingo
Installation
Clingo-Explaid easily be installed with pip
:
pip install clingexplaid
Requirements
python >= 3.9
clingo >= 5.7.1
Building from Source
Please refer to DEVELOPEMENT
API
Here are two example for using clingexplaid
's API.
Minimal Unsatisfiable Subsets (MUS)
import clingo
from clingexplaid.transformers import AssumptionTransformer
from clingexplaid.mus import CoreComputer
PROGRAM = """
a(1..3).
{b(4..6)}.
a(X) :- b(X).
:- a(X), X>=3.
"""
control = clingo.Control()
at = AssumptionTransformer(signatures={("a", 1)})
transformed_program = at.parse_string(PROGRAM)
control.add("base", [], transformed_program)
control.ground([("base", [])])
assumptions = at.get_assumption_literals(control)
cc = CoreComputer(control, assumptions)
def shrink_on_core(core) -> None:
mus_literals = cc.shrink(core)
print("MUS:", cc.mus_to_string(mus_literals))
control.solve(assumptions=list(assumptions), on_core=shrink_on_core)
Unsatisfiable Constraints
from clingexplaid.unsat_constraints import UnsatConstraintComputer
PROGRAM = """
a(1..3).
{b(4..6)}.
a(X) :- b(X).
:- a(X), X>=3.
"""
ucc = UnsatConstraintComputer()
ucc.parse_string(PROGRAM)
unsat_constraints = ucc.get_unsat_constraints()
for uc_id, unsat_constraint in unsat_constraints.items():
print(f"Unsat Constraint {uc_id}:", unsat_constraint)
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
clingexplaid-1.1.0.tar.gz
(72.0 kB
view details)
Built Distribution
File details
Details for the file clingexplaid-1.1.0.tar.gz
.
File metadata
- Download URL: clingexplaid-1.1.0.tar.gz
- Upload date:
- Size: 72.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2208b7fc213415e3ec590ca726882e0c166b1e861387e5b9df2ed70753aeed48 |
|
MD5 | a14f2e1c0167029e97b371d08b8436dd |
|
BLAKE2b-256 | 9cb37c1d97a00930d6057d5926189f892a87755f2f98ead3c6f6115c7af11a21 |
File details
Details for the file clingexplaid-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: clingexplaid-1.1.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73bc677f40e67d307c2ec27da10874b901aa00a269398704595ba2ea11986620 |
|
MD5 | 8e81ce0daf8aa20979353e31ad3c1667 |
|
BLAKE2b-256 | 002f4b98eb5922fdce9b1fbea6699a9fbee5eec0e0e4d6ff66e3ad33c62fc6f9 |