docs← Back to article

Markdown for LLMs

Assemble qualification from elements

The source Markdown for this article. Copy it into your assistant or download it as a text file.

Download this articlePlain text ↗
# Assemble qualification from elements

## Intent

I want to derive the elements of an offence only when every element is established.

## Wrong form and why it stays silent

```text title="Incorrect form"
// Освобождение от ответственности удаляет один из элементов или сам offence.
```

Qualification, liability, and exemption are different conclusions. Withdrawal is addressed at liable; offence is preserved.

## Correct form

```law
language "law.core" version "0.2";
package recipes.g.r07 version "0.1.0";
namespace "urn:recipe:g-concepts:07";

entity Person;
relation eligible(p: Person) kind institutional;
relation young(p: Person) kind empirical;
relation act(p: Person);
relation culpable(p: Person);
relation offence(p: Person);
relation exempt(p: Person);
relation liable(p: Person);
rule Qualify strict { for p: Person; when act(p) and culpable(p); then offence(p); }
rule Liability defeasible { for p: Person; when offence(p); then liable(p); unless exempt(p); }
```

## Frozen execution scene

| Facts on 13.09.2026 | Question | Answer |
|---|---|---|
| all elements | `truth(offence(entity_ref("urn:recipe:g-concepts:07:p")))` | `truth_status == TRUE_ONLY;` / `COMPUTED` |
| an element missing | `truth(offence(entity_ref("urn:recipe:g-concepts:07:p")))` | `truth_status == NEITHER;` / `COMPUTED` |
| exemption, elements preserved | `truth(offence(entity_ref("urn:recipe:g-concepts:07:p")))` | `truth_status == TRUE_ONLY;` / `COMPUTED` |
| liability withdrawn | `truth(liable(entity_ref("urn:recipe:g-concepts:07:p")))` | `truth_status == NEITHER;` / `COMPUTED` |

```law
test "complete elements constitute offence" {
    given {
        context {
            legal_time @2026-09-13;
            decision_time @2026-09-13T09:00:00+05:00;
            knowledge_time @2026-09-13T09:00:00+05:00;
            timezone "Asia/Almaty";
        }
        assert act(entity_ref("urn:recipe:g-concepts:07:p")); assert culpable(entity_ref("urn:recipe:g-concepts:07:p"));
    }
    evaluate truth(offence(entity_ref("urn:recipe:g-concepts:07:p")));
    expect truth_status == TRUE_ONLY;
    expect evaluation_status == COMPUTED;
}
```

```law
test "missing element stays unknown" {
    given {
        context {
            legal_time @2026-09-13;
            decision_time @2026-09-13T09:00:00+05:00;
            knowledge_time @2026-09-13T09:00:00+05:00;
            timezone "Asia/Almaty";
        }
        assert act(entity_ref("urn:recipe:g-concepts:07:p"));
    }
    evaluate truth(offence(entity_ref("urn:recipe:g-concepts:07:p")));
    expect truth_status == NEITHER;
    expect evaluation_status == COMPUTED;
}
```

```law
test "exemption preserves composition" {
    given {
        context {
            legal_time @2026-09-13;
            decision_time @2026-09-13T09:00:00+05:00;
            knowledge_time @2026-09-13T09:00:00+05:00;
            timezone "Asia/Almaty";
        }
        assert act(entity_ref("urn:recipe:g-concepts:07:p")); assert culpable(entity_ref("urn:recipe:g-concepts:07:p")); assert exempt(entity_ref("urn:recipe:g-concepts:07:p"));
    }
    evaluate truth(offence(entity_ref("urn:recipe:g-concepts:07:p")));
    expect truth_status == TRUE_ONLY;
    expect evaluation_status == COMPUTED;
}
```

```law
test "lifted liability stays unknown" {
    given {
        context {
            legal_time @2026-09-13;
            decision_time @2026-09-13T09:00:00+05:00;
            knowledge_time @2026-09-13T09:00:00+05:00;
            timezone "Asia/Almaty";
        }
        assert act(entity_ref("urn:recipe:g-concepts:07:p")); assert culpable(entity_ref("urn:recipe:g-concepts:07:p")); assert exempt(entity_ref("urn:recipe:g-concepts:07:p"));
    }
    evaluate truth(liable(entity_ref("urn:recipe:g-concepts:07:p")));
    expect truth_status == NEITHER;
    expect evaluation_status == COMPUTED;
}
```

The exception is wrongly moved into Qualify: with exemption, offence disappears.

```law
test "exemption on composition rule removes offence" {
    given {
        context {
            legal_time @2026-09-13;
            decision_time @2026-09-13T09:00:00+05:00;
            knowledge_time @2026-09-13T09:00:00+05:00;
            timezone "Asia/Almaty";
        }
        assert act(entity_ref("urn:recipe:g-concepts:07:p")); assert culpable(entity_ref("urn:recipe:g-concepts:07:p")); assert exempt(entity_ref("urn:recipe:g-concepts:07:p"));
    }
    evaluate truth(offence(entity_ref("urn:recipe:g-concepts:07:p")));
    expect truth_status == NEITHER;
    expect evaluation_status == COMPUTED;
}
```

```python
>>> import runpy
>>> check = runpy.run_path("docs/recipes/g-concepts/resources/check.py")
>>> check["check_variant"](https://github.com/arxohq/law/blob/master/docs/recipes/g-concepts/7)
'Г7: контрфактуал подтверждён; lawc = lawref'
```

## Counterfactual

Mutation `rule Liability defeasible` → `rule Liability strict`: LDC-E4110.

## Boundary

The set of elements is given by the source. The presence of fact act does not prove culpable; channels of guilt and judgment are separate profiles.