afsolver
A lightweight Python solver for Dung-style abstract argumentation framework (AF) semantics: conflict-free, admissible, complete, preferred, grounded, and stable.
Install
uv add afsolver
or with pip:
pip install afsolver
Quick start
from afsolver import ArgumentationFramework
af = ArgumentationFramework(
arguments=["a", "b", "c"],
attacks=[("a", "b"), ("b", "a"), ("c", "b")], # a<->b mutual attack, c attacks b
)
af.preferred() # [frozenset({'a', 'c'})]
af.grounded() # frozenset({'a', 'c'})
af.extensions() # dict with all six semantics at once
arguments is optional — if omitted, arguments are inferred from the
attacks pairs (deduplicated, in order of first appearance):
af = ArgumentationFramework(attacks=[("b", "a"), ("c", "b"), ("d", "c")])
af.arguments # ('b', 'a', 'c', 'd')
Attack pairs can be tuples or lists — both are accepted and normalized to tuples internally.
API
ArgumentationFramework(arguments=(), attacks=())
| Method | Returns |
|---|---|
.conflict_free() |
list[frozenset] — conflict-free sets |
.admissible() |
list[frozenset] — admissible sets |
.complete() |
list[frozenset] — complete extensions |
.preferred(contains=None) |
list[frozenset] — preferred (maximal admissible) extensions, optionally restricted to those containing all arguments in contains |
.grounded() |
frozenset — the (unique) grounded extension |
.stable() |
list[frozenset] — stable extensions |
.minimal_admissible(contains=None) |
list[frozenset] — non-empty admissible sets minimal by set inclusion, optionally restricted to those containing all arguments in contains |
.extension(name) |
dispatch to any of the six semantics above by string name |
.extensions() |
dict[str, ...] — all six semantics computed at once |
preferred with a contains filter
Restrict the preferred extensions to those that include a given argument (or set of arguments) — useful for credulous-acceptance-style queries:
af = ArgumentationFramework(
["a", "b", "c", "d", "e"],
[("b", "a"), ("c", "b"), ("d", "b"), ("c", "e"), ("e", "c")],
)
af.preferred() # [{'a', 'c', 'd'}, {'a', 'd', 'e'}]
af.preferred(contains=["a", "c"]) # [{'a', 'c', 'd'}]
minimal_admissible
Useful for finding the smallest admissible sets that justify including a given argument (or set of arguments):
af = ArgumentationFramework(
["a", "b", "c", "d", "e"],
[("b", "a"), ("c", "b"), ("d", "b"), ("c", "e"), ("e", "c")],
)
af.minimal_admissible() # [{'c'}, {'d'}, {'e'}]
af.minimal_admissible(contains=["a"]) # [{'a', 'c'}, {'a', 'd'}]
The empty set is always excluded — it's trivially admissible and a subset of everything else, so including it would hide the smallest non-trivial results.
Development
uv sync # install project + dev dependencies
uv run pytest -q # run tests
uv build # build sdist + wheel
Metadata
Release files for afsolver 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| afsolver-0.1.0.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| afsolver-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / afsolver-0.1.0.tar.gz
| Download URL | afsolver-0.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4664196c6357c24b3f0657c460e9152588213285081ba9b7dcc4ab8a15100320
|
|
BLAKE2b-256 checksum How to use checksums |
f631d60a12b39d939abadd8cbfce72d641e4bae6f3d67ba51da1ac5f96e05d10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / afsolver-0.1.0-py3-none-any.whl
| Download URL | afsolver-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cad4e609ec207dce52b72cd472dfb069a7240b554c2e326f93045840bf69f48a
|
|
BLAKE2b-256 checksum How to use checksums |
7a46b080d88c716589fe1102055535081e41001115b31b49fdfd9a862efc0dd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Security for afsolver 0.1.0
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.