Markdown for LLMs
Walk a chain with strict recursion
The source Markdown for this article. Copy it into your assistant or download it as a text file.
# Walk a chain with strict recursion
## Intention
I want to derive reachability along a finite chain of relations.
## Incorrect form and why it stays silent
A recursive bare reader forms a status cycle:
```text title="Incorrect form"
when reach(a, b) and edge(b, c);
then reach(a, c);
```
## Correct form
```law
language "law.core" version "0.2";
package recipes.v.r07 version "0.1.0";
namespace "urn:recipe:v-negation:07";
entity Person;
relation edge(a: Person, b: Person);
relation reach(a: Person, b: Person);
rule Base strict {
for a: Person; for b: Person;
when edge(a, b);
then reach(a, b);
}
rule Step strict {
for a: Person; for b: Person; for c: Person;
when monotone(reach(a, b)) and edge(b, c);
then reach(a, c);
}
```
## Frozen execution scene
| Facts | Question | Answer |
|---|---|---|
| edge(a,b), edge(b,c) | reach(a,c) | TRUE_ONLY |
| edge(a,b) | reach(a,c) | NEITHER |
| no base facts | reach(a,c) | NEITHER |
| replace monotone with bare | check | E4102 |
```law
test "linked edges reach far end" {
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 edge(entity_ref("urn:recipe:v-negation:07:a"), entity_ref("urn:recipe:v-negation:07:b"));
assert edge(entity_ref("urn:recipe:v-negation:07:b"), entity_ref("urn:recipe:v-negation:07:c"));
}
evaluate truth(reach(entity_ref("urn:recipe:v-negation:07:a"), entity_ref("urn:recipe:v-negation:07:c")));
expect truth_status == TRUE_ONLY;
expect applied(Step);
}
```
```law
test "single edge reaches nowhere" {
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 edge(entity_ref("urn:recipe:v-negation:07:a"), entity_ref("urn:recipe:v-negation:07:b"));
}
evaluate truth(reach(entity_ref("urn:recipe:v-negation:07:a"), entity_ref("urn:recipe:v-negation:07:c")));
expect truth_status == NEITHER;
}
```
```law
test "no edges yield nothing" {
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(reach(entity_ref("urn:recipe:v-negation:07:a"), entity_ref("urn:recipe:v-negation:07:c")));
expect truth_status == NEITHER;
}
```
## Counterfactual
teaches drops monotone from the recursive reading and gets E4102. The two-edge scene confirms the transitive step; the scene without a base excludes spontaneous support.
## Boundary
Every reading inside the cycle must be monotone; empirical edge does not recurse. This form does not compute a previous round and does not allow a cycle through an aggregate. Names and computed values join only under compatible terms; a universal ban “two monotones do not join” is false.
## Pitfall
Read the recursive step with monotone, not supported: supported is the deliberate disputed-fact reading of [Use a disputed fact deliberately](/recipes/v-negation/consume-conflict/), and using it for ordinary recursion needlessly lifts the whole package to a higher stratum.