# lawref.evaluator.argumentation

*module*

Профиль structured argumentation [§274.1](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2741-область-и-вход)–[§274.7](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2747-результат-и-проверяемость) (law.argumentation/0.2,
DECISION-0039; С-2 плана LAYERS-NEXT).

Отдельный вид запроса `argumentation`; baseline 0.1 не тронут — профиль
читает те же принятые утверждения [§73](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/11-part-xi-assertions-facts-evidence.ru.md#73-origin) и правила пакета, но строит СВОЮ
семантику: рекурсивные структурные аргументы (стратификация [§110](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/16-part-xv-defeasible-semantics-and-conflict-resolution.ru.md#110-stratification) не
требуется), атаки rebut/undermine/undercut [§274.3](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2743-атаки), побеждения по
[§106](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/16-part-xv-defeasible-semantics-and-conflict-resolution.ru.md#106-priority-relation)-приоритетам last-link [§274.4](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2744-побеждения), grounded/preferred разметки [§274.5](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2745-семантики-af) и
классы ответа [§274.6](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2746-классы-ответа).

Сила правила решает его роль (errata E-0237): strict | defeasible дают
шаги ЗА свою голову; `defeater` (голое `unless` [§149](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/20-part-xix-definitions-presumptions-fictions-exceptions.ru.md#149-unless), [§107](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/16-part-xv-defeasible-semantics-and-conflict-resolution.ru.md#107-defeat) п. 3) даёт
ДЕФИТЕР-АРГУМЕНТ — ту же структуру `step`, чьё заключение есть цель
поражения, а не довод: он не служит под-аргументом чужого шага, не входит
в `argumentsFor` и атакует defeasible-шаг той же головы undercut-ом. Терминируемость — запрет повторов ground-заключений на пути
([§274.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2742-аргументы)): чиcло ground-атомов конечно, глубина ограничена, множество
аргументов конечно; капы [§274.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2742-аргументы)/[§274.5](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2745-семантики-af) делают отказ от перебора явным
(fatal RESOURCE_LIMIT, частичный вывод не публикуется).

Детерминизм [§211](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/29-part-xxviii-compiler-pipeline.ru.md#211-determinism): структуры аргументов упорядочиваются каноническими
байтами [§208](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/28-part-xxvii-canonical-legal-ir.ru.md#208-canonical-serialization), id — порядковые; все списки результата отсортированы.

## lawref.evaluator.argumentation.DEFAULT_MAX_ARGUMENTS

*attribute* · *module attribute*

```python
DEFAULT_MAX_ARGUMENTS = 64
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L33-L33)

## lawref.evaluator.argumentation.DEFAULT_MAX_EXTENSIONS

*attribute* · *module attribute*

```python
DEFAULT_MAX_EXTENSIONS = 8
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L34-L34)

## lawref.evaluator.argumentation.DEFAULT_MAX_UNDECIDED

*attribute* · *module attribute*

```python
DEFAULT_MAX_UNDECIDED = 16
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L35-L35)

## lawref.evaluator.argumentation.ProfileLimit

*class*

```python
class ProfileLimit(Exception)
```

Bases: `Exception`

Превышен кап [§274.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2742-аргументы)/[§274.5](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2745-семантики-af) — fatal RESOURCE_LIMIT без частичного
вывода (дисциплина [§238](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/31-part-xxx-scalability.ru.md#238-resource-limits)).

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L42-L49)

### lawref.evaluator.argumentation.ProfileLimit.counter

*attribute* · *instance attribute*

```python
counter = counter
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L48-L48)

### lawref.evaluator.argumentation.ProfileLimit.limit

*attribute* · *instance attribute*

```python
limit = limit
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L49-L49)

## lawref.evaluator.argumentation.answer_class

*function*

```python
def answer_class(target: dict, ordered: list[dict], ids: dict[bytes, str], grounded: dict[str, list[str]], extensions: list[list[str]]) -> dict
```

Класс ответа [§274.6](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2746-классы-ответа) для цели.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L361-L377)

## lawref.evaluator.argumentation.build_arguments

*function*

```python
def build_arguments(rules: list[dict], leaves: list[dict], max_arguments: int) -> list[dict]
```

Фикспойнт построения [§274.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2742-аргументы). Множество аргументов конечно (запрет
повторов на пути) и не зависит от порядка перебора; кап проверяется на
числе РАЗЛИЧНЫХ аргументов, поэтому вердикт о превышении тоже
порядко-независим.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L181-L226)

## lawref.evaluator.argumentation.compute_attacks

*function*

```python
def compute_attacks(ordered: list[dict], ids: dict[bytes, str], reach: dict[str, set[str]]) -> list[dict]
```

Атаки [§274.3](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2743-атаки) и их побеждаемость [§274.4](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2744-побеждения) (last-link по [§106](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/16-part-xv-defeasible-semantics-and-conflict-resolution.ru.md#106-priority-relation)-замыканию;
взаимная достижимость = несравнимость, побеждение остаётся).

Точка-шаг атакуема только при силе defeasible: strict — restricted
rebut, шаг дефитер-аргумента ничего не утверждает (E-0237). Rebut идёт
от аргументов ЗА противоположный литерал, undercut — от
дефитер-аргументов с тем же заключением; оба побеждают, если правило
точки не старше правила атакующего ([§107](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/16-part-xv-defeasible-semantics-and-conflict-resolution.ru.md#107-defeat) п. 3).

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L242-L291)

## lawref.evaluator.argumentation.eligible_rules

*function*

```python
def eligible_rules(nodes: list[dict], legal_time: str) -> tuple[list[dict], list[dict]]
```

(пригодные правила с разобранными конъюнктами, skippedRules [§274.1](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2741-область-и-вход)).

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L64-L102)

## lawref.evaluator.argumentation.evaluate_profile

*function*

```python
def evaluate_profile(nodes: list[dict], store, registry, target: dict, legal_time: str, limits: dict | None = None) -> dict
```

Полный прогон профиля; результат — value-словарь [§274.7](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2747-результат-и-проверяемость).

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L392-L428)

## lawref.evaluator.argumentation.fact_leaves

*function*

```python
def fact_leaves(store, registry) -> list[dict]
```

Лист-факты [§274.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2742-аргументы): литералы, у которых есть accepted-опора [§73](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/11-part-xi-assertions-facts-evidence.ru.md#73-origin)
(сторона store, содержащая id принятого утверждения).

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L105-L120)

## lawref.evaluator.argumentation.grounded_labelling

*function*

```python
def grounded_labelling(arg_ids: list[str], defeats: dict[str, set[str]]) -> dict[str, list[str]]
```

Grounded [§274.5](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2745-семантики-af): наименьшая неподвижная точка in/out/undec.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L294-L313)

## lawref.evaluator.argumentation.preferred_extensions

*function*

```python
def preferred_extensions(arg_ids: list[str], defeats: dict[str, set[str]], grounded: dict[str, list[str]], max_undecided: int, max_extensions: int) -> list[list[str]]
```

Preferred [§274.5](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/39-part-xxxvii-open-issues-0-2.ru.md#2745-семантики-af): перебор подмножеств undec-ядра поверх grounded-in
(каждое preferred содержит grounded-in и не содержит grounded-out),
admissibility-фильтр, затем максимальность по включению.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/evaluator/argumentation.py#L316-L358)
