Repository navigation
Description
compute_attacks does not finish within 180 seconds on a small generated ASPIC+ theory: 8 literals, 4 ordinary premises, 11 strict rules and 3 defeasible rules. build_arguments turns this theory into 18,850 arguments in about 0.5s, and 18,496 of those arguments conclude p. The property test tests/structured/aspic/test_aspic.py::TestAttackProperties::test_rebutting_targets_defeasible_conclusions generated the theory. Hypothesis saved it in a local .hypothesis database; after that, the test hit the 600s pytest timeout on every run, and pytest then raised a MemoryError while formatting the traceback. Main CI passes this test because CI starts with an empty database.
Theory (shrunk by Hypothesis)
- Language:
p, q, r, sand their negations, with each atom and its negation contradictory. - Ordinary premises:
q, s, ~p, ~r. There are no axioms. - Strict rules:
p -> ~sq, ~r -> sq, ~s -> rs -> ~p~p, ~q -> q~q, ~p -> q~q, ~q -> p~r, q -> s~r, ~s -> ~q~s, q -> r~s, ~r -> ~q
- Defeasible rules:
r, q => ~r(namedd0)s => q(namedd3)~p => ~s(namedd1)
Reproduction
Run with the repository development environment (uv run python repro.py), with an external timeout as the bound. At ad3c01c plus the #96 branch:
import time
from argumentation.structured.aspic.aspic import (
ArgumentationSystem, ContrarinessFn, GroundAtom, KnowledgeBase, Literal, Rule,
build_arguments, compute_attacks,
)
P, Q, R, S = (Literal(GroundAtom(n)) for n in "pqrs")
NP, NQ, NR, NS = (a.contrary for a in (P, Q, R, S))
strict = frozenset(Rule(b, h, "strict") for b, h in [
((P,), NS), ((Q, NR), S), ((Q, NS), R), ((S,), NP), ((NP, NQ), Q), ((NQ, NP), Q),
((NQ, NQ), P), ((NR, Q), S), ((NR, NS), NQ), ((NS, Q), R), ((NS, NR), NQ)])
defeasible = frozenset({Rule((R, Q), NR, "defeasible", "d0"),
Rule((S,), Q, "defeasible", "d3"),
Rule((NP,), NS, "defeasible", "d1")})
system = ArgumentationSystem(frozenset({P, Q, R, S, NP, NQ, NR, NS}),
ContrarinessFn(frozenset((a, a.contrary) for a in (P, Q, R, S))), strict, defeasible)
kb = KnowledgeBase(axioms=frozenset(), premises=frozenset({Q, S, NP, NR}))
t = time.perf_counter(); args = build_arguments(system, kb)
print(len(args), "arguments", round(time.perf_counter() - t, 2), "s")
compute_attacks(args, system) # does not return within 180 sOperational evidence (AGENTS.md)
build_arguments: 18,850 arguments in 0.40–0.54s.- Arguments per conclusion:
p18,496,r144,~q136,s31,q18,~r17,~p4,~s4. - Rebut attack points (a sub-argument whose top rule is defeasible): 98,849. Rebutting attack pairs: 8,687,712. This counts rebuttals only; undermining pairs are extra.
compute_attacksstill had not returned when killed at 180s.- Profile: py-spy, 30s at 50 Hz on the real interpreter rather than the uv launcher, 1,499 samples. The top leaf frames are
compute_attacksat aspic.py:1159–1164, the loop that adds oneattack_keysentry per (attack point, candidate attacker) pair, withArgument.__hash__(aspic.py:249) behind it. The cost is the size of the attack relation itself, not one slow step.
The underlying shape is argument multiplication. Cyclic strict rules, including ones with a repeated antecedent (~q, ~q -> p) and mirrored bodies (~p, ~q -> q / ~q, ~p -> q), give p 18,496 structurally distinct arguments. Each rebuttable sub-argument then pairs with every argument for the contrary conclusion.
Expected
The finite theory should be decided within a bounded budget, or the test generators should not produce theories whose argument sets explode. Which of those, if either, is a design decision for this issue. A useful first operational contract would be to bound len(build_arguments(...)) and the attack-pair count on this theory, so the regression fails fast instead of timing out.
No production change is included in this report.
Activity
ctoth commentedon Sep 27, 2026
Investigation: evidence, papers and fix options
No production change yet. All probes ran on
main052775e.Evidence
The cost is the size of the output, not a slow algorithm.
compute_attacksalready indexes attackers by conclusion:candidate_attackersis built once per target literal, so there is no pairwise scan to remove. A py-spy profile on the real interpreter confirms the report above: all the time is in the loop that emits one attack at a time (aspic.py:1159-1164), plusArgument.__hash__. Measured cost is about 3.3 µs per emitted attack: a variant of this theory with 800 arguments and 569,330 attacks took 1.9 s incompute_attacks.The attack relation is larger than reported above. Counted without materialising it, from per-conclusion argument counts:
About 306M
Attackobjects is roughly 17 minutes at the measured rate, plus several GB of memory, whatever algorithm produces them.Where the arguments multiply: of the 18,850 arguments, 18,496 conclude
p. That is exactly 136²: the rule~q, ~q -> pcombines two independent~qarguments, and there are 136 of them. Permuted duplicate rules multiply further:~p,~q -> qand~q,~p -> q, and~r,~s -> ~qand~s,~r -> ~q.~q,~q -> pbecomes~q -> p)How the test generator produced this theory:
strict_rules()intests/structured/aspic/test_aspic.pydraws antecedents with replacement, which gave the seed~q,~q -> p.transposition_closurekeeps antecedent positions, so that one seed became the two permuted rules(~p,~q) -> qand(~q,~p) -> q.Papers
A1, ..., An -> φfrom a ruleConc(A1), ..., Conc(An) -> φ. Neither requires arguments to be minimal. The only construction-time filter is c-consistency (M&P Def 11), andbuild_argumentsalready applies it. Under this sequence reading,~q,~q -> papplied to two different~qarguments is a genuinely distinct argument, whose premise set is the union of both.Operational contract
On this theory, assert
len(build_arguments(...)) <= 200, and assert that the attack-pair count, computed from per-conclusion counts without callingcompute_attacks, is at most 20,000. This is deterministic and runs in under a second. Today it fails at 18,850 arguments and about 306M pairs. Under option A it would pass at 98 arguments and 7,226 pairs.Fix options
Separate test-only fix (PR to follow, Refs #102)
xfail(strict=True)until option A lands.Merge pull request #103 from ctoth/test/aspic-generator-bounds
ctoth commentedon Sep 28, 2026
Decision recorded: strict-rule antecedents are read as sets (option A1 + A2)
The maintainer chose option A1 + A2 from the investigation above. The fix is in PR #104 (branch
fix/aspic-rule-sets).Convention. Modgil & Prakken 2018, Def 2 (p.8) and Def 5 (p.9), and Prakken 2010, Def 3.6, write a rule as
φ1, ..., φn → φand build an argumentA1, ..., An → φfrom it. Neither text fixes whether the antecedents form a sequence or a set. This library now chooses the set reading for strict rules, as a convention:~q, ~q → pis the rule~q → p.~p, ~q → qand~q, ~p → qare the same rule).Semantic effect:
~q, ~q → pbuilt one argument for p per ordered pair of ~q arguments. Those combined arguments no longer exist; there is one argument per ~q argument. This is the deliberate semantic change.Where it lives. The canonicalisation happens in
Rule.__post_init__, at rule construction. As a result, every producer gets the same reading without any per-producer code:transposition_closure, Datalog grounding, hand-built systems and ABA rules.Producer audit:
transposition_closureemits canonical rules.body_countis consistent, because ABA strict rules are now canonical. A probe of a defeasible rule with a repeated antecedent also agrees between the native and ASP backends.Result on the #102 theory: 18,850 → 98 arguments, and about 306M → 7,226 attack pairs. The pinned operational contract (at most 200 arguments and at most 20,000 attack pairs) now passes, and its
xfailmarker is removed.fix: read defeasible-rule antecedents as sets too
ctoth commentedon Sep 28, 2026
Decision extended by the maintainer: the set reading now applies to defeasible rules too (PR #104). A repeated antecedent literal is dropped, and unnamed defeasible rules with the same antecedent set and consequent merge. Named defeasible rules stay distinct by n(r), so undercuts still target the named rule. Canonicalisation happens once, in
Rule.__post_init__, for every rule kind. Full suite: 3511 passed, 7 skipped, 1 xfailed.