engine.rulesets.owl2_rl_lists

Expand OWL 2 RL LIST[h, e1, ..., en] abbreviations into triple conditions.

OWL 2 Profiles Section 4.3 Table 3 expands list atoms into rdf:first / rdf:rest / rdf:nil conjunctions. Fresh rest-cell variables z2 … zn are introduced for list cells after the head.

Functions

owl2_rl_list_conditions(...)

Expand LIST[head, *elements] into Table 3 TripleCondition tuples.

Module Contents

engine.rulesets.owl2_rl_lists.owl2_rl_list_conditions(head: engine.rules.PatternTerm, elements: tuple[engine.rules.PatternTerm, Ellipsis] | list[engine.rules.PatternTerm], *, cell_prefix: str = 'z') → tuple[engine.rules.TripleCondition, Ellipsis]

Expand LIST[head, *elements] into Table 3 TripleCondition tuples.

For n = len(elements) >= 1 the expansion is:

  • T(head, rdf:first, e1) and T(head, rdf:rest, z2) (or rdf:nil when n == 1)

  • for each subsequent element ei (2 <= i < n): T(zi, rdf:first, ei) and T(zi, rdf:rest, z{i+1})

  • for the final element when n >= 2: T(zn, rdf:first, en) and T(zn, rdf:rest, rdf:nil)

Fresh cell variables are named {cell_prefix}2 … {cell_prefix}{n}. Callers that use more than one list abbreviation in the same rule body SHOULD choose distinct cell_prefix values so those variables stay fresh.

This helper only builds read-only match conditions. It does not mutate graphs or register builtins.

Parameters:
  • head – List head term or variable (h in the OWL 2 Profiles abbreviation).

  • elements – Ordered list element terms or variables (e1 … en). At least one element is required.

  • cell_prefix – Prefix for fresh intermediate cell variables. Defaults to "z" so cells are z2 … zn as in Table 3.

Returns:

Ordered TripleCondition values implementing the Table 3 expansion.

Raises:

ValueError – If elements is empty.