Skip to main content

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:

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 no contains argument, returns all preferred extensions. Pass contains to restrict the result to only those that include 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.preferred()                     # [{'a', 'c', 'd'}, {'a', 'd', 'e'}]
af.preferred(contains=["a", "c"])  # [{'a', 'c', 'd'}]

minimal_admissible

With no contains argument, returns the smallest non-trivial admissible sets overall. Pass contains to restrict the result to the smallest admissible sets that include 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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afsolver 0.1.1
File Size Uploaded Provenance
afsolver-0.1.1.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 12.6 kB

Release files / afsolver-0.1.1.tar.gz

Download URL afsolver-0.1.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
45359a3c520bd4cf47f3ff2e4fb93ee8821a4275097a22d29fd42b0cf6999894
BLAKE2b-256 checksum
How to use checksums
cdfb97023785879fa9e4121b50742dc37f70141c1488277de99cbd172255e489
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.5

Release files / afsolver-0.1.1-py3-none-any.whl

Download URL afsolver-0.1.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c97e0cde9720b787a81b047a59f448b659a6a6bd8901969112f2436c78bf7039
BLAKE2b-256 checksum
How to use checksums
1cfd14fb38be5d0bc6d8d5bc3f0737426d6343c90d5f2c4f6d6e9d7f24753994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.5

Security for afsolver 0.1.1

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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