Equal values and distinct positions
Intention
Section titled “Intention”I want to keep equal amounts of different charges when summing.
Equal values of different entities collapse in a Set; the scenes repeat the case on two charges of 500 KZT.
Incorrect form and why it stays silent
Section titled “Incorrect form and why it stays silent”sum(collect x: Money, c: Charge where amount(c, x))Set collapses equal amount values even when the charges are different. List keeps every substitution; the number of charges is counted over the entities themselves.
Correct form
Section titled “Correct form”language "law.core" version "0.2";package recipes.l.r11 version "0.1.0";namespace "urn:recipe:l-calc:11";
entity Charge;relation amount(c: Charge, x: Money) { key(c); }relation total(x: Money);rule Total strict { when true; then total(sum(collect all x: Money, c: Charge where amount(c, x))); }Frozen execution scene
Section titled “Frozen execution scene”| Facts and choice | Question | Answer |
|---|---|---|
| 1. two equal positions, List | truth(total(1000 KZT)) | TRUE_ONLY / COMPUTED |
| 2. counterfactual: duplicate preservation removed | truth(total(500 KZT)) | TRUE_ONLY / COMPUTED |
| 3. number of amount values | count(collect x: Money, c: Charge where amount(c, x)) | 1 / COMPUTED |
| 4. number of charges | count(collect c: Charge, x: Money where amount(c, x)) | 2 / COMPUTED |
two equal positions as list
test "two equal positions as list" { 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 amount(entity_ref("urn:recipe:l-calc:11:a"), 500 KZT); assert amount(entity_ref("urn:recipe:l-calc:11:b"), 500 KZT); } evaluate truth(total(1000 KZT)); expect truth_status == TRUE_ONLY; expect evaluation_status == COMPUTED;
}duplicate preservation removed
test "duplicate preservation removed" { 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 amount(entity_ref("urn:recipe:l-calc:11:a"), 500 KZT); assert amount(entity_ref("urn:recipe:l-calc:11:b"), 500 KZT); } evaluate truth(total(500 KZT)); expect truth_status == TRUE_ONLY; expect evaluation_status == COMPUTED;
}count of sum values
test "count of sum values" { 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 amount(entity_ref("urn:recipe:l-calc:11:a"), 500 KZT); assert amount(entity_ref("urn:recipe:l-calc:11:b"), 500 KZT); } evaluate count(collect x: Money, c: Charge where amount(c, x)); expect value == 1; expect evaluation_status == COMPUTED;
}count of charges
test "count of charges" { 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 amount(entity_ref("urn:recipe:l-calc:11:a"), 500 KZT); assert amount(entity_ref("urn:recipe:l-calc:11:b"), 500 KZT); } evaluate count(collect c: Charge, x: Money where amount(c, x)); expect value == 2; expect evaluation_status == COMPUTED;
}Counterfactual
Section titled “Counterfactual”Mutation: x: Money, c: Charge where amount(c, x) → x: Money where amount(c, x); expected LDC-E1317. Additional counterfactuals are shown as separate table rows.
Boundary
Section titled “Boundary”collect all does not remove extra substitutions over grounds — that is Sum over items, not over grounds. Choosing List for the sum and Set for entities does not replace a completeness check of input facts.
Pitfall
Section titled “Pitfall”Two equal charges are one value but two positions: count them over the entities, not the amounts.
Documentation for Arxo. Writings — blog.arxo.io.
Anonymous visit counts on stats.arxo.io, no cookies.