For the complete documentation index, see llms.txt. This page is also available as Markdown.

Rules and expressions

Write valid inference rules, conditions, variables, and expressions in RBlang.

Rule structure

Rules are relationship instances with nested conditions.

<relinst type="is eligible" object="true" cf="100" name="Eligible if 18+">
    <condition rel="has age" subject="%S" object="%AGE"/>
    <condition expression="%AGE is greater than or equal to 18"/>
</relinst>

Use these rule attributes:

  • type β€” the relationship being inferred

  • object β€” the inferred value when it is fixed

  • cf β€” certainty factor

  • alt β€” alternative evidence text shown in the evidence tree

  • name β€” optional rule name

Rule names do not need to be unique. Keep them under 170 characters.

Evidence text

Rule attributes and condition attributes support alt.

In Studio, alt is called evidence text.

Use it to return a clearer explanation in the evidence tree.

That explanation appears alongside the fact.

It can be shown instead of the raw fact text.

Variables can be used in alt text, but they must be wrapped in {{ }}.

Variables

Variables start with %.

  • %S β€” the current subject

  • %O β€” the output object

  • custom names such as %AGE or %RESULT

Use relationship conditions to bind values.

Use expression conditions to test or calculate values.

Critical expression rules

Correct assignment:

Invalid assignment:

String comparisons

Use single quotes around string literals.

Missing facts

Do not test for null directly.

Use countRelationshipInstances() instead.

Multi-step calculations

Break complex logic into separate steps.

Condition weighting and behaviour

Conditions can influence certainty and success.

  • mandatory β€” must be satisfied

  • optional β€” adds confidence when satisfied

Authoring guidance

Keep each rule focused on one result.

Write rules for the general case. Do not hard-code output values that only fit one example dataset.

Last updated