Skip to content
docs
Arxo ↗

LDC-E2122 — A comparison across two different enumerations

For LLMs5 sections

Members of an enumeration compare only within their own enumeration: the comparison goes by the member identity, and members of different enumerations are incomparable rather than unequal. At execution such a comparison would poison the whole document instead of answering false, so the compiler refuses the guard statically at the comparison.

The fix compares within one enumeration — a member against a value of the same enumeration — or relates the two values through a relation instead of comparing them directly. Ordering comparisons over enumerations are refused the same way, since ordering is undefined over them entirely.

Arxo Law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";
entity P;
enum RiskLevel { Low, High }
enum Stage { First, Last }
relation level_of(p: P, l: RiskLevel) kind empirical;
relation stage_of(p: P, s: Stage) kind empirical;
relation ok(p: P) kind institutional;
rule R strict { for p: P; for l: RiskLevel; for s: Stage; when level_of(p, l) and stage_of(p, s) and (l == First); then ok(p); }
Arxo Law
language "law.core" version "0.2";
package demo.diagnostics version "0.1.0";
namespace "urn:law:demo:diagnostics";
entity P;
enum RiskLevel { Low, High }
enum Stage { First, Last }
relation level_of(p: P, l: RiskLevel) kind empirical;
relation stage_of(p: P, s: Stage) kind empirical;
relation ok(p: P) kind institutional;
rule R strict { for p: P; for l: RiskLevel; for s: Stage; when level_of(p, l) and stage_of(p, s) and (l == Low); then ok(p); }

The engine reports this in its own wording:

Output
example.law:11:103: error LDC-E2122: «==»: operands belong to different enums — RiskLevel and Stage (§57): enum comparison goes by the member §38 stable qualified identity, and members of DIFFERENT enums are incomparable (errata E-0067) — execution answers TYPE_ERROR, poisoning the whole document, not `false`. Compare operands of one enum or relate them by a relation

Documentation for Arxo. Writings — blog.arxo.io.

Anonymous visit counts on stats.arxo.io, no cookies.