Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ and CQ11 choice-stage objections.
pairs *uncertain*. Pairs over A × A are partitioned into `attacks`,
`ignorance`, and `non_attacks`; reasoning is by enumerating *completions*. The
module also provides three merge aggregations (`sum_merge_frameworks`,
`max_merge_frameworks`, `leximax_merge_frameworks`) and `consensual_expand`.
`max_merge_frameworks`, `leximax_merge_frameworks`) and
`consensual_expand(framework, profile)`. Expansion preserves the source's
commitments and imports uncontested attack and non-attack relations from the
profile; conflicting outside pairs remain uncertain.

`argumentation.dynamics.af_revision` adds arguments and attacks to an existing
framework, or revises an extension state by a formula or by a target
Expand Down
31 changes: 31 additions & 0 deletions agent-notes/fix-paper-code-corrections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Paper-derived code corrections

## Goal
Correct the five confirmed implementation mismatches identified after the visual paper-note audit. Make each correction its own commit, then publish the complete series as one PR. Q authorized this on 2026-10-19; the earlier "make it so" remains in the session. Leave the PR open for review; do not merge it under the earlier notes-only integration instruction.

## State
Branch `fix/paper-code-corrections` starts at origin/main `1e1029e5539c3783dcabca95b0e958761867814a` in `C:/Users/Q/code/argumentation-paper-code-corrections`. All five scoped corrections are implemented and checked against the original paper page images. Four separate commits already exist: `6a2a33a` (impact), `d308240` (distance), `152277f` (expansion), and `4682283` (classification). The fifth commit contains transposition closure and this record update. No local tests, typecheck, build, or other CI steps have run. Publication and hosted CI are next. Preserve the primary checkout's uncommitted audit record and all unrelated artifacts. The failed old temporary-directory cleanup is outside this task.

## Decisions and why
- Smallest change: fix the existing functions and the existing assertions/generators that encode their incorrect contracts. Roughly 100-180 production lines and comparable or fewer test/doc lines across five commits; no new public framework, flags, compatibility facade, solver optimization, or new guards.
- Commit 1: revised impact removes external attacks entering X, and target-preserving node deletion removes edges touching all of X. Correct existing self-attack expectations. About 20-35 production lines.
- Commit 2: PAF edit distance charges 0/0.5/1 per Definition 18; update objective annotations and existing expectations. About 10-20 production lines.
- Commit 3: consensual expansion receives the profile, imports uncontested outside relations, and is used by the existing merge operators. Update all current callers/docs and assertions. About 35-65 production lines.
- Commit 4: classify Cayrol extension-family changes using the paper's cardinalities, quantifiers, and decisive precedence. Correct existing mistaken tests. About 15-30 production lines.
- Commit 5: transposition closure retains all seed strict rules and generated transpositions; remove unsupported pruning and revise existing generator restrictions. About 10-25 production lines removed/changed.
- Paper evidence is exclusively original page images in the primary checkout. No extraction, OCR, or extracted-paper-text navigation. No local CI steps; use hosted PR CI. No new tests/guards; correct existing tests where they encode a wrong contract.
- Workers own disjoint source/test/doc paths and do not commit. The primary stages only each correction's owned paths and commits them separately. PAF distance and expansion share files and therefore run sequentially.
- Consensual expansion now takes the full profile as its second argument; all repository callers and API documentation were updated. Passing only a universe cannot determine the paper's consensual relations.
- The closure correction removes unsupported pruning rather than adding machinery. Its existing nontrivial-argument property now excludes a rule whose consequent is already an antecedent, matching the argument builder's existing restriction to non-repeating conclusion paths. Changing argument enumeration is outside these five corrections.

## Source evidence
- AlAnaissy 2024 original images 001,003-004: external incoming attacks, node/edge deletion, self-attack example.
- Coste-Marquis 2007 original images 006-010: generic versus consensual expansion, Example 14, edit distance.
- Cayrol (local 2014 directory, actual 2010 publication) original images 006,008-011,016: structural classifications and examples.
- Prakken 2010 original image 012: Definitions 5.1-5.3, extensive closure under every transposition.

## Surprises
The existing tests asserted positive self-impact and whole-unit ignorance distance, accepted expansive classification with unequal family counts, and excluded valid transpositions. Those expectations and generator restrictions are corrected alongside the implementation. The argument builder still restricts repeated conclusions; this series does not claim to settle broader argument-enumeration completeness.

## Next step
Commit closure as the fifth correction, then push and open one combined PR for hosted validation on its exact head. Leave the PR open. Stop and report any execution/check failure under the standing instructions.
3 changes: 3 additions & 0 deletions docs/af-revision.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ minimal faithful candidates.
classifies the effect of adding an argument under grounded semantics using the
WS-B taxonomy values in `AFChangeKind`: decisive, restrictive, questioning,
destructive, expansive, conservative, and altering.
The classifier uses the paper's extension-family counts: an empty grounded
extension becoming nonempty is decisive. Expansive change requires equal
counts and every new extension strictly containing an old extension.

## Gates

Expand Down
4 changes: 3 additions & 1 deletion docs/argumentation-package-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ wrappers live in `argumentation.solver`; CEL authoring, `ConditionIR`,
and mapping-like claim metadata.

`argumentation.partial_af` owns partial-framework completion enumeration,
completion queries, exact edit-distance merge operators, and `consensual_expand`.
completion queries, exact edit-distance merge operators, and
`consensual_expand(framework, profile)`, which preserves source commitments and
imports uncontested profile relations, leaving conflicting outside pairs ignorant.

`argumentation.af_revision` owns AF-level revision and accepts formula-like
extension constraints through an argumentation-owned protocol. Propstore
Expand Down
4 changes: 2 additions & 2 deletions docs/structured-argumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ Compare both `Prem_p` (ordinary premises) and `DefRules` (all defeasible rules)

Transposition closure (Def 12, p.13; Prakken 2010 Def 5.1) ensures that strict rules interact correctly with contrariness. For each strict rule `A1, ..., An -> C` and each antecedent index `i`, a transposed rule is generated: `A1, ..., ~C, ..., An -> ~Ai`. This process repeats until a fixpoint is reached.

**Degenerate rule filtering**: transposed rules with contradictory antecedent pairs are discarded (they reference Thm 14, direct consistency). After the fixpoint, an axiom consistency check verifies that no literal's strict closure contains its own contrary.
Prakken 2010 Definition 5.2 requires the closure to contain every input rule and every transposition. Rules with contradictory antecedents, and rules whose consequent also occurs among their antecedents, are retained. Consistency requirements for a particular knowledge base are separate from this rule-set closure.

Transposition closure is required for the rationality postulates (Thms 12-15) to hold. Without it, the framework can produce inconsistent extensions — arguments that are jointly accepted but whose conclusions contradict each other under strict rules.

`argumentation/src/argumentation/aspic.py:247` — `transposition_closure()`
`src/argumentation/structured/aspic/aspic.py` — `transposition_closure()`

## Rationality Postulates

Expand Down
28 changes: 11 additions & 17 deletions src/argumentation/dynamics/af_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,11 @@ def _classify_extension_change(
) -> AFChangeKind:
"""Classify structural extension change after an AF update.

Cayrol, de Saint-Cyr, and Lagasquie-Schiex 2010, JAIR 38, Table 3
distinguishes seven extension-family changes by content relations between
the old and new extension families, not by cardinality alone.
Cayrol, de Saint-Cyr, and Lagasquie-Schiex 2010, JAIR 38, Definitions
8-14 and Table 2 distinguish changes in the number of extensions first.
Expansive change preserves that number, and every new extension must
strictly contain an old one. A transition from the empty grounded
extension to one nonempty extension is decisive.
"""
before_set = frozenset(frozenset(extension) for extension in before)
after_set = frozenset(frozenset(extension) for extension in after)
Expand All @@ -394,24 +396,16 @@ def _classify_extension_change(
return AFChangeKind.CONSERVATIVE
if not after_set or after_set == empty_family:
return AFChangeKind.DESTRUCTIVE
if (
before_set
and after_set
and all(any(old < new for new in after_set) for old in before_set)
if len(after_set) == 1 and (
len(before_set) >= 2 or before_set in {frozenset(), empty_family}
):
return AFChangeKind.EXPANSIVE
if len(after_set) == 1:
survivor = next(iter(after_set))
if survivor in before_set or before_set in {frozenset(), empty_family}:
return AFChangeKind.DECISIVE
return AFChangeKind.DECISIVE
if len(before_set) < len(after_set):
return AFChangeKind.QUESTIONING
if (
before_set
and after_set
and all(any(new <= old for old in before_set) for new in after_set)
):
if len(after_set) < len(before_set):
return AFChangeKind.RESTRICTIVE
if all(any(old < new for old in before_set) for new in after_set):
return AFChangeKind.EXPANSIVE
return AFChangeKind.ALTERING


Expand Down
15 changes: 7 additions & 8 deletions src/argumentation/frameworks/af_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ def _candidate_frameworks(

def _expanded_profile(
profile: dict[str, ArgumentationFramework],
universe: frozenset[str],
) -> dict[str, PartialArgumentationFramework]:
return {
source: consensual_expand(framework, universe)
source: consensual_expand(framework, profile)
for source, framework in profile.items()
}

Expand Down Expand Up @@ -112,7 +111,7 @@ def sum_merge_frameworks(
) -> list[ArgumentationFramework] | EnumerationExceeded:
"""Return exact Sum-minimizing AFs over the shared argument universe."""
universe = _shared_universe(profile)
expanded = _expanded_profile(profile, universe)
expanded = _expanded_profile(profile)
strict_bipartition_winners = _strict_bipartition_sum_merge(universe, expanded)
if strict_bipartition_winners is not None:
return strict_bipartition_winners
Expand All @@ -121,7 +120,7 @@ def sum_merge_frameworks(
if isinstance(candidates, EnumerationExceeded):
return candidates

best_score: int | None = None
best_score: float | None = None
winners: list[ArgumentationFramework] = []
for candidate in candidates:
score = sum(
Expand All @@ -143,12 +142,12 @@ def max_merge_frameworks(
) -> list[ArgumentationFramework] | EnumerationExceeded:
"""Return exact Max-minimizing AFs over the shared argument universe."""
universe = _shared_universe(profile)
expanded = _expanded_profile(profile, universe)
expanded = _expanded_profile(profile)
candidates = _candidate_frameworks(universe, max_candidates=max_candidates)
if isinstance(candidates, EnumerationExceeded):
return candidates

best_score: int | None = None
best_score: float | None = None
winners: list[ArgumentationFramework] = []
for candidate in candidates:
score = max(
Expand All @@ -170,12 +169,12 @@ def leximax_merge_frameworks(
) -> list[ArgumentationFramework] | EnumerationExceeded:
"""Return exact Leximax-minimizing AFs over the shared argument universe."""
universe = _shared_universe(profile)
expanded = _expanded_profile(profile, universe)
expanded = _expanded_profile(profile)
max_winners = max_merge_frameworks(profile, max_candidates=max_candidates)
if isinstance(max_winners, EnumerationExceeded):
return max_winners

best_vector: tuple[int, ...] | None = None
best_vector: tuple[float, ...] | None = None
winners: list[ArgumentationFramework] = []
for candidate in max_winners:
vector = tuple(
Expand Down
102 changes: 57 additions & 45 deletions src/argumentation/frameworks/partial_af.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Partial argumentation frameworks and completion-based queries."""

from __future__ import annotations

from dataclasses import dataclass
from __future__ import annotations

from collections.abc import Mapping
from dataclasses import dataclass
from enum import StrEnum
from itertools import combinations, product
from typing import TypeAlias, cast
Expand Down Expand Up @@ -140,22 +141,31 @@ def _coerce_partial_framework(
raise TypeError(f"Unsupported framework type: {type(framework)!r}")


def merge_framework_edit_distance(
left: FrameworkLike,
right: FrameworkLike,
) -> int:
"""Hamming distance over pair labels on a shared argument universe."""
def merge_framework_edit_distance(
left: FrameworkLike,
right: FrameworkLike,
) -> float:
"""Coste-Marquis et al. 2007, Definition 18 edit distance over pair labels.

Equal labels cost zero, ignorance versus a definite label costs 0.5,
and attack versus non-attack costs one on the shared argument universe.
"""

left_framework = _coerce_partial_framework(left)
right_framework = _coerce_partial_framework(right)
if left_framework.arguments != right_framework.arguments:
raise ValueError("merge_framework_edit_distance requires identical arguments")

return sum(
1
for pair in left_framework.ordered_pairs
if left_framework.state_of(pair) != right_framework.state_of(pair)
)
return sum(
(
0.5
if pair in left_framework.ignorance or pair in right_framework.ignorance
else 1.0
for pair in left_framework.ordered_pairs
if left_framework.state_of(pair) != right_framework.state_of(pair)
),
0.0,
)


_COMPLETION_SEMANTICS: frozenset[str] = frozenset({"grounded", "preferred", "stable"})
Expand Down Expand Up @@ -207,38 +217,40 @@ def _attack_relation(framework: ArgumentationFramework) -> frozenset[AttackPair]
return framework.attacks if framework.attacks is not None else framework.defeats


def consensual_expand(
framework: ArgumentationFramework,
universe: frozenset[str],
) -> PartialArgumentationFramework:
"""Expand an AF to a shared universe using ignorance outside source scope.

Coste-Marquis et al. 2007, Def. 11 takes the universe as the union of the
profile's argument sets, so it must contain the source arguments.
"""
source_arguments = frozenset(framework.arguments)
missing = source_arguments - universe
if missing:
raise ValueError(
f"universe must contain every source argument; missing {sorted(missing)!r}"
)
attack_relation = _attack_relation(framework)
attacks: set[AttackPair] = set()
ignorance: set[AttackPair] = set()
non_attacks: set[AttackPair] = set()

for pair in product(universe, universe):
attacker, target = pair
if attacker in source_arguments and target in source_arguments:
if pair in attack_relation:
attacks.add(pair)
else:
non_attacks.add(pair)
else:
ignorance.add(pair)

return PartialArgumentationFramework(
arguments=universe,
def consensual_expand(
framework: ArgumentationFramework,
profile: Mapping[str, ArgumentationFramework],
) -> PartialArgumentationFramework:
"""Expand an AF using the profile's uncontested attack commitments.

Coste-Marquis et al. 2007, Definition 12 preserves the source's attacks
and non-attacks, imports uncontested relations outside its scope, and
leaves only conflicting outside pairs ignorant. Pairs known to no source
become non-attacks. The universe includes the source and every profile AF.
"""
source_arguments = frozenset(framework.arguments)
universe = set(source_arguments)
profile_attacks: set[AttackPair] = set()
profile_non_attacks: set[AttackPair] = set()
for source in profile.values():
universe.update(source.arguments)
relation = _attack_relation(source)
profile_attacks.update(relation)
profile_non_attacks.update(
set(product(source.arguments, source.arguments)) - relation
)

source_attacks = _attack_relation(framework)
source_non_attacks = (
set(product(source_arguments, source_arguments)) - source_attacks
)
conflicts = profile_attacks & profile_non_attacks
attacks = source_attacks | ((profile_attacks - conflicts) - source_non_attacks)
ignorance = conflicts - (source_attacks | source_non_attacks)
non_attacks = set(product(universe, universe)) - (attacks | ignorance)

return PartialArgumentationFramework(
arguments=frozenset(universe),
attacks=frozenset(attacks),
ignorance=frozenset(ignorance),
non_attacks=frozenset(non_attacks),
Expand Down
20 changes: 11 additions & 9 deletions src/argumentation/gradual/gradual.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ def revised_direct_impact(
) -> RevisedImpactResult:
"""Compute the revised removal-based impact of ``influencers`` on ``target``.

Al Anaissy et al. 2024, Definition 12: remove direct attacks from the
influencer set to the target, and compare against target-preserving argument
deletion. The latter keeps ``target`` when it is also in ``influencers``,
which makes self-attack attribution defined.
Al Anaissy et al. 2024, Definitions 10 and 12: first remove external
attacks entering the influencer set, then compare against deletion of that
set. Argument deletion retains ``target`` but removes relations incident
on any influencer, isolating the target when it is an influencer itself.
"""
normalized_influencers = frozenset(str(argument) for argument in influencers)
target = str(target)
Expand All @@ -315,7 +315,7 @@ def revised_direct_impact(
removed_attacks = frozenset(
(source, attacked)
for source, attacked in graph.attacks
if source in normalized_influencers and attacked == target
if source not in normalized_influencers and attacked in normalized_influencers
)
attack_removed = _without_attacks(graph, removed_attacks)
after_attack_removal = quadratic_energy_strengths(
Expand All @@ -330,7 +330,7 @@ def revised_direct_impact(
)

removed_arguments = normalized_influencers - {target}
argument_removed = _without_arguments(graph, removed_arguments)
argument_removed = _without_arguments(graph, normalized_influencers, target=target)
after_argument_removal = quadratic_energy_strengths(
argument_removed,
tolerance=tolerance,
Expand Down Expand Up @@ -458,8 +458,10 @@ def _without_attacks(
def _without_arguments(
graph: WeightedBipolarGraph,
removed_arguments: frozenset[str],
*,
target: str,
) -> WeightedBipolarGraph:
remaining = graph.arguments - removed_arguments
remaining = graph.arguments - (removed_arguments - {target})
return WeightedBipolarGraph(
arguments=remaining,
initial_weights={
Expand All @@ -468,11 +470,11 @@ def _without_arguments(
attacks=frozenset(
(source, target)
for source, target in graph.attacks
if source in remaining and target in remaining
if source not in removed_arguments and target not in removed_arguments
),
supports=frozenset(
(source, target)
for source, target in graph.supports
if source in remaining and target in remaining
if source not in removed_arguments and target not in removed_arguments
),
)
Loading
Loading