Skip to content
EN FR

Relations, contexts and named terms

Documentation status: reference — see Maturity and evidence.

H-Logic keeps relations polyadic and role-aware. Context is modeled as an ordinary typed role, and environment values are referenced explicitly with &.

Relations

define .:#Transfer(sender:#Person, receiver:#Person, amount:#Money, context:#Context);

Use a simple role reference when a relation is only structural. Reify a relation when the fact needs its own identity, metadata, persistence, lifecycle, actions, confidence, provenance or validity interval.

define .:#BelongsTo(entityA:#Entity, entityB:#Entity);
fact1:#BelongsTo(#child, #parent);

A named relational fact can itself carry attributes or participate in further relations.

Context is a role

define .:#Context(me)[label::#string];
define .:#VisibleIn(item:#Item, context:#Context);

Do not use a pseudo-function such as context(projectBeta). Bind a context role explicitly.

Named terms

projectBeta := #projectBeta;
exists target=&projectBeta on .:#VisibleIn(label42, target);

The & prefix means “resolve this named value from the environment”. It is not part of the logical name and cannot be used as a role name.

Fixed and default values

define .:#FixedScope(context:#Context=&globalContext);
define .:#DefaultScope(context:#Context default &globalContext);

A fixed value constrains resolution. A default supplies a value only when none is provided.

Role domains

Logical role domains can be expressed explicitly, for example role:(#A or #B). For reusable subset semantics, prefer a named type in the graph rather than an ad-hoc constructor-like domain.