# lawref.unit_declarations

*module*

Нормализация объявлений атомов ДО [§209](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/28-part-xxvii-canonical-legal-ir.ru.md#209-theory-hash-и-artifact-hash) (E-0150, DECISION-0157).

Поверхностный сахар хранится только во входе authoring; выход — UnitDecl
вида simple. Алгебра значений [§49.1](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/08-part-viii-type-system.ru.md#491-алгебра-размерностей-magnitude-errata-e-0136-decision-0154) остаётся в units.py.

## lawref.unit_declarations.expression

*function*

```python
def expression(text, resolve)
```

Точный множитель и вектор RHS; никаких ambient constants ([§49.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/08-part-viii-type-system.ru.md#492-объявление-единиц-errata-e-0136-e-0150)).

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

## lawref.unit_declarations.fail

*function*

```python
def fail(message: str, code: str = 'UNIT_UNKNOWN')
```

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

## lawref.unit_declarations.lower_units

*function*

```python
def lower_units(source: str, imported: list[dict] = ()) -> list[dict]
```

Оракульный читатель только деклараций [§49.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/08-part-viii-type-system.ru.md#492-объявление-единиц-errata-e-0136-e-0150), не всего языка.

Заголовки и feature-аннотации не несут вычислений. Неизвестный текст
декларации отвергается; полный синтаксис пакета проверяет компилятор.

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

## lawref.unit_declarations.normalize

*function*

```python
def normalize(declarations: list[dict], imported: list[dict] = ()) -> list[dict]
```

Нормализует тела UnitDecl, RHS задаётся полем expression ([§49.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/08-part-viii-type-system.ru.md#492-объявление-единиц-errata-e-0136-e-0150)).

imported — узлы закреплённого мира, без догадок о неявном SI.
Никакого expression в возвращённых узлах нет.

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

## lawref.unit_declarations.positive

*function*

```python
def positive(num, den)
```

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

## lawref.unit_declarations.powers

*function*

```python
def powers(pairs)
```

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