Markdown for LLMs
Declare relation functionality
The source Markdown for this article. Copy it into your assistant or download it as a text file.
# Declare relation functionality
## Intent
I want to detect two values of one key while keeping both facts.
## Wrong form and why it stays silent
```text title="Incorrect form"
// При двух адресах ключ выбирает последний; при отсутствии адреса доказывает отрицание.
```
KEY_CONFLICT reports two incompatible projections without deleting either. A key does not give completeness and does not prove that a row exists.
## Correct form
```law
language "law.core" version "0.2";
package recipes.g.r11 version "0.1.0";
namespace "urn:recipe:g-concepts:11";
entity Person;
relation address(p: Person, city: Text) kind empirical { key(p); }
relation eligible(p: Person);
rule Registered strict { for p: Person; for city: Text; when address(p, city); then eligible(p); }
```
## Frozen execution scene
| Facts on 13.09.2026 | Question | Answer |
|---|---|---|
| first value kept | `truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "A"))` | `truth_status == TRUE_ONLY; issue(KEY_CONFLICT);` / `NON_EXECUTABLE` |
| second value kept | `truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "B"))` | `truth_status == TRUE_ONLY; issue(KEY_CONFLICT);` / `NON_EXECUTABLE` |
| address unknown | `truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "A"))` | `truth_status == NEITHER;` / `COMPUTED` |
| key removed | `truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "A"))` | `truth_status == TRUE_ONLY; not issue(KEY_CONFLICT);` / `COMPUTED` |
```law
test "first value kept under conflict" {
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 address(entity_ref("urn:recipe:g-concepts:11:p"), "A"); assert address(entity_ref("urn:recipe:g-concepts:11:p"), "B");
}
evaluate truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "A"));
expect truth_status == TRUE_ONLY; expect issue(KEY_CONFLICT);
expect evaluation_status == NON_EXECUTABLE;
}
```
```law
test "second value kept under conflict" {
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 address(entity_ref("urn:recipe:g-concepts:11:p"), "A"); assert address(entity_ref("urn:recipe:g-concepts:11:p"), "B");
}
evaluate truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "B"));
expect truth_status == TRUE_ONLY; expect issue(KEY_CONFLICT);
expect evaluation_status == NON_EXECUTABLE;
}
```
```law
test "unknown address 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";
}
}
evaluate truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "A"));
expect truth_status == NEITHER;
expect evaluation_status == COMPUTED;
}
```
```law
test "removed key restores truth" {
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 address(entity_ref("urn:recipe:g-concepts:11:p"), "A"); assert address(entity_ref("urn:recipe:g-concepts:11:p"), "B");
}
evaluate truth(address(entity_ref("urn:recipe:g-concepts:11:p"), "A"));
expect truth_status == TRUE_ONLY; expect not issue(KEY_CONFLICT);
expect evaluation_status == COMPUTED;
}
```
## Counterfactual
Mutation `key(p);` → `key(missing);`: LDC-E1304.
## Boundary
An issue with error severity forbids a COMPUTED document: CONSTRAINT_VIOLATED and KEY_CONFLICT make the whole document NON_EXECUTABLE. This does not erase the fact’s truth status and does not change the constraint verdict.
Choosing a single value requires only and cardinality handling. Two positive tuples do not make each atom BOTH: this is a data conflict, not negative support.